Difference between below commands | Selenium Forum
M
Posted on 11/08/2016
In module 20 2016 videos ,

you implemented java script function for frames page to open completely
commad is js.executescript( "return document.readystate")
and wait till state become complete

There is one more command driver.manage().timeouts().pageLoadTimeout(05, TimeUnit.SECONDS);

whats the difference between these two commands ? do they work same?

M
Replied on 11/08/2016

public void waitForPageToLoad() {
wait(1);
JavascriptExecutor js=(JavascriptExecutor)driver;
String state = (String)js.executeScript("return document.readyState");

while(!state.equals("complete")){
wait(2);
state = (String)js.executeScript("return document.readyState");
}
}

The above code will wait till the page is fully loaded and continues further.

The below code waits only for 5 seconds, it cannot be guaranteed that the page can be loaded in 5 seconds or any other value.

driver.manage().timeouts().pageLoadTimeout(05, TimeUnit.SECONDS);