0
votes

I am using selenium web driver 3.4.0 to find the response time of a website..In earlier version , I have used WebDriver wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("myId"))); to find the page loaded.

But these two lines of code not working for version 3.4.0. is there any other way to calculate the load time of a page? Or wait until the page gets loaded? Also I need to detect the modal dialog which will be loaded on button click. I am implementing using dynamic web project in eclipse IDE.

I also need to wait for some moment until some click event finished loading Dom element. Wait.until() is not working for selenium 3.4.0. how to make selenium wait until some element is visible ?

1
new WebDriveraWait().until() is not working for selenium version 3.4.0.. it throws no method found error!!sherin shaf

1 Answers

0
votes

You can use JavascriptExecutor to get the ready state of the page, and pass it as an expected condition to your wait.until()

Here is the reference code for this,

ExpectedCondition<Boolean> expectation = new
            ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver driver) {
            return ((JavascriptExecutor) driver).executeScript("return document.readyState").toString().equals("complete");
        }
    };
    try {
        Thread.sleep(1000);
        WebDriverWait wait = new WebDriverWait(LocalDriverManager.getDriver(), 30);
        wait.until(expectation);
    } catch (Throwable error) {
        Assert.fail("Timeout waiting for Page Load Request to complete.");
    }