【发布时间】:2019-08-17 22:55:30
【问题描述】:
我的网页上有一个元素在页面加载后几乎立即由 AJAX 更新。我知道我期望更改是什么,并希望 Selenium 等待更改并捕获它。我正在尝试对此使用显式等待。但是,由于 Selenium 未检测到更改,我收到了 timeoutException。
我知道我在使用打印语句时正确选择了元素和值。我已经使用
解决了这个问题Java Thead.sleep(1000)
然后使用
driver.findElement(By.id("balance-sms")).getText()
但这不是一个可接受的解决方案。
private void modalSend(String newBalence){
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(modalSendButton)); //this wait works fine
modalSendButton.click(); //this results in a page refresh
//now check for the AJAX change to this element...normally takes about 1 second
wait.until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.id("balance-sms")),newBalence));
//continue...
}
【问题讨论】:
-
编辑页面上的文本的代码试验?你看到了什么错误?
-
超时异常
标签: java ajax selenium webdriverwait