From 261f88dd19e63ad171d06e46d6e63628ac6f3539 Mon Sep 17 00:00:00 2001 From: Tim Oliver <97861664+tim-mediasuite@users.noreply.github.com> Date: Tue, 29 Mar 2022 14:10:29 +1300 Subject: [PATCH] FIX When waiting for text to show on page, look for elements until we find one that is visible instead (#211) of failing if the first element is invisible. --- src/Context/BasicContext.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Context/BasicContext.php b/src/Context/BasicContext.php index 4e2552be..468af3f4 100644 --- a/src/Context/BasicContext.php +++ b/src/Context/BasicContext.php @@ -1151,16 +1151,20 @@ public function iWaitUntilISeeText($text) $page = $this->getSession()->getPage(); $session = $this->getSession(); $this->spin(function () use ($page, $session, $text) { - $element = $page->find( + $elements = $page->findAll( 'xpath', $session->getSelectorsHandler()->selectorToXpath("xpath", ".//*[contains(text(), '$text')]") ); - - if (empty($element)) { - return false; - } else { - return ($element->isVisible()); + foreach ($elements as $element) { + if (empty($element)) { + continue; + } + if (!$element->isVisible()) { + continue; + } + return true; } + return false; }); }