Wednesday, September 10, 2014

How to continue refreshing a page until the element is loaded

Sometimes we need to continue refreshing the page until an specific element is loaded. In that case we need to write some extra code beside selenium webdriver command.

We can use do…While() loop using the specific element as locator and the function “isDisplayed()” to detect that the element is appeared. We run the loop until we get the element loaded on the page. Every time we execute the refresh() method under the loop.

            // Reload the page

}while(the specific element is not displayed);

In Java,

I think this will help those who are fighting with element loading problem.
Happy Selenium Webdrivering!!!