How would we make sure that a page is loaded using Selenium and WebDriver?
While automating the script, the tester has to take care that the page is loaded properly otherwise on performing some action execution will fail.
There are some ways defined below to make sure the page is loaded :
1.Using loading spinner:
While the page is loading there is a loading spinner on the web page, the tester can wait for the invisibility of that spinner
(new WebDriverWait(webDriver, 120)).until(ExpectedConditions.invisibilityOfElementLocated(by));
2.By using JavascriptExecutor :
It is an interface which provides a mechanism to execute JavaScript through selenium web driver
((JavascriptExecutor) webDriver).executeScript("return document.readyState").equals("complete")
Comments
Post a Comment