WebDriver:如何等待文本在元素中消失

Ser*_*Kim 1 webdriver selenium-webdriver

我有一个动态更改其文本的字段.我需要一种等待文本更改的方法.我不知道会出现什么文字,但我知道目前有哪些文字.所以我想等待它消失在元素中.有办法吗?

nil*_*esh 6

你可以尝试ExpectedConditions 函数textToBePresentInElement并添加一个not,比如,

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