public function waitForElementUntilIsPresentWithSpecificText(By $locator, $targetText, $timeOutSeconds = 5) { $dynamicElement = null; $wait = true; $attempts = $timeOutSeconds; while ($wait) { $currentText = null; $webDriverWait = new WebDriverWait($timeOutSeconds); $dynamicElement = $webDriverWait->until($this, "findElement", array($locator, true)); try { $currentText = $dynamicElement->getText(); } catch (SeleniumStaleElementReferenceException $ex) { //echo "\nError The Objet Disappear, Wait For Element Until Is Present With Specific Text\n"; } if ($currentText == $targetText) { $wait = false; } else { if ($attempts <= 0) { throw new Exceptions\WebDriverWaitTimeout("Timeout for waitForElementUntilIsPresentAndTextIsChange."); } } sleep(1); $attempts = $attempts - 1; } return $dynamicElement; }