Java wait until page load using Selenium

1368 views java
-5

So i want to wait until page load using Selenium.

This is my implementation:

public static boolean isPageLoad(String url) {
    try {
        new WebDriverWait(driver, 30).until(ExpectedConditions.urlToBe(url));
        return true;
    } catch (Exception ex) {
        return false;
    }
}

So do you think this should be enough or i need maybe to add another check for example search also the body tag ?

answered question

1 Answer

4

You can just set the pageLoadTimeout when initializing the WebDriver

WebDriver driver = new ChromeDriver();
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);

posted this

Have an answer?

JD

Please login first before posting an answer.