How do you make Selenium 2.0 wait for the page to load?
Here is a Java 8 version of the currently most upvoted answer:
WebDriverWait wait = new WebDriverWait(myDriver, 15);
wait.until(webDriver -> ((JavascriptExecutor) myDriver).executeScript("return document.readyState").toString().equals("complete"));
Where myDriver
is a WebDriver
object (declared earlier).
Note: Be aware that this method (document.readyState
) only checks the DOM.