Skip to content

Instantly share code, notes, and snippets.

@azakordonets
Created June 2, 2014 10:17
Show Gist options
  • Select an option

  • Save azakordonets/62e7778bbb405fd4a0ce to your computer and use it in GitHub Desktop.

Select an option

Save azakordonets/62e7778bbb405fd4a0ce to your computer and use it in GitHub Desktop.
This method allows you to properly wait for page in load with WebDriver
public void waitForPageToLoad() {
Wait<WebDriver> wait = new WebDriverWait(manager.getDriver(), 30);
wait.until(new Function<WebDriver, Boolean>() {
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");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment