我有以下代码等待ajax调用完成,在Firefox和chrome浏览器中工作正常,但在safari中却不能。非常感谢任何帮助!
wait.until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(final WebDriver driver) {
try {
if ((Boolean) ((JavascriptExecutor) driver).executeScript("return !!document['readyState'];")) {
if ((Boolean) ((JavascriptExecutor) driver)
.executeScript("return 'complete' == document.readyState;")) {
if ((Boolean) ((JavascriptExecutor) driver).executeScript(
"if (typeof jQuery !== 'undefined') { return jQuery.active == 0;} return true;")) {
return true;
}
}
}
} catch (final Exception e) {
// Just continue...
}
return false;
}
});