WebDriver: how to wait for text to disappear in the element

selenium-webdriverwebdriver

I have a field that dynamically changes it's text. I need a way to wait for the text to be changed. I'm not aware about what text will appear, but I know what text is currently there. So i'd like to wait for it to disappear in the element. Is there a way for this?

Best Answer

You can Try ExpectedConditions function textToBePresentInElement and add a not, like,

WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = driver.findElement(By.id("foo"));
wait.until(ExpectedConditions.not(
    ExpectedConditions.textToBePresentInElement(element,"textToBePresent")));