Nearsoft\SeleniumClient\WebElement::waitForElementUntilIsPresentWithSpecificText PHP Method

waitForElementUntilIsPresentWithSpecificText() public method

Wait until current element's text equals specified
public waitForElementUntilIsPresentWithSpecificText ( By $locator, String $targetText, integer $timeOutSeconds = 5 ) : Nearsoft\SeleniumClient\WebElement
$locator By
$targetText String
$timeOutSeconds integer
return Nearsoft\SeleniumClient\WebElement
    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;
    }