我经常使用此例程,并且在使用Firefox进行测试时可以正常运行。在Chrome上运行时,它似乎挂了很长时间。
public static boolean isloadComplete(WebDriver driver) {
printLine();
myPrint(thisClass + " isloadComplete.");
myPrint(thisClass + " wait for load to complete.");
try {
return ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("loaded")
|| ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete");
} catch (Exception e) {
int errorCode = 1540894984;
System.err.println(thisClass + " error code: " + errorCode +" Exception: " + e.getMessage());
throw e;
}
}