Skip to content

Commit

Permalink
FIX When waiting for text to show on page, look for elements until we…
Browse files Browse the repository at this point in the history
… find one that is visible instead (#211)

of failing if the first element is invisible.
  • Loading branch information
tim-mediasuite authored Mar 29, 2022
1 parent 8ff1ef7 commit 261f88d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Context/BasicContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}

Expand Down

0 comments on commit 261f88d

Please sign in to comment.