How do you make Selenium 2.0 wait for the page to load?
You may remove the System.out
line. It is added for debug purposes.
WebDriver driver_;
public void waitForPageLoad() {
Wait wait = new WebDriverWait(driver_, 30);
wait.until(new Function() {
public Boolean apply(WebDriver driver) {
System.out.println("Current Window State : "
+ String.valueOf(((JavascriptExecutor) driver).executeScript("return document.readyState")));
return String
.valueOf(((JavascriptExecutor) driver).executeScript("return document.readyState"))
.equals("complete");
}
});
}