public static function visibilityOfAnyElementLocated(WebDriverBy $by)
    {
        return new static(
            function (WebDriver $driver) use ($by) {
                $elements = $driver->findElements($by);
                $visibleElements = [];

                foreach ($elements as $element) {
                    try {
                        if ($element->isDisplayed()) {
                            $visibleElements[] = $element;
                        }
                    } catch (StaleElementReferenceException $e) {
                    }
                }

                return count($visibleElements) > 0 ? $visibleElements : null;
            }
        );
    }