public void waitForPageLoad(WebDriver driver){
while(true){
String page_status =(String)((JavascriptExecutor)driver).executeScript("return document.readyState");
if(page_status.equals("complete")){
break;
}
}
}
I saw people using the above method in framework to wait till page finishes the JS loading.
But why to write this method as the selenium scripts doesn't execute when we navigate to next page and the page isn't loaded completely.
I guess this is used if any action made is refreshing the page, say removing a product from the cart of a online shopping site ?
Am i correct or is there any other reason ?