等待元素中出现的文本不是提供的字符串

Waiting until text to be present in element is NOT the string provided

我正在寻找一种方法让 selenium webdriver 等待,直到出现在我感兴趣的元素位置的文本不是下面代码中提供的字符串。

wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath("//*[@id=\"order-details\"]/div[2]/div/dl/dd[1]/div"),"Completed successfully"));

我正在寻找 "text to be present" 不是 "Completed successfully" 的方法,这样代码就可以继续前进,不再等待

你可以试试ExpectedConditions - not

WebElement element = driver.findElement(By.xpath("//*[@id=\"order-details\"]/div[2]/div/dl/dd[1]/div"));
wait.until(ExpectedConditions.not(ExpectedConditions.textToBePresentInElement(element, "Completed successfully")));