org.openqa.selenium.TimeoutException:預期條件失敗: (試過10 秒與500毫秒的間隔)爲什麼我的代碼無法正常工作並出現以下錯誤?
這裏是我的代碼:
public static ExpectedCondition<Boolean> waitForTextToChange(final WebElement element, final String currentText) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver arg0) {
return !element.getText().equals(currentText);
}
};
}
使用代碼:
WebElement element = driver.findElement(...);
String currentText = element.getText();
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(waitForTextToChange(element, currentText));