How to wait for a page to load in Selenium

A good indication that the page has loaded is when the document object’s readyState property is “complete”.
You can use a custom wait to wait for this.

Java

Wait<WebDriver> wait = new WebDriverWait(driver, 30);
wait.until(new Function<WebDriver, Boolean>() {
    public Boolean apply(WebDriver driver) {
        return String
            .valueOf(((JavascriptExecutor) driver).executeScript("return document.readyState"))
            .equals("complete");

Python

class document_is_ready(object):
    def __call__(self, driver)
        return driver.execute_script("return document.readyState").equals("complete"))

C#

IWait<IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(30.00));
wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").
                          Equals("complete"));