Wait for page load in Selenium

后端 未结 30 2509
攒了一身酷
攒了一身酷 2020-11-22 07:12

How do you make Selenium 2.0 wait for the page to load?

30条回答
  •  失恋的感觉
    2020-11-22 07:58

    Imran's answer rehashed for Java 7:

        WebDriverWait wait = new WebDriverWait(driver, 30);
    
        wait.until(new ExpectedCondition() {
            public Boolean apply(WebDriver wdriver) {
                return ((JavascriptExecutor) driver).executeScript(
                    "return document.readyState"
                ).equals("complete");
            }
        });
    

提交回复
热议问题