I am writing some Java Webdriver code to automate my application. How can I correctly check whether the page has been loaded or not? The application has some Ajax calls, too
Recently, when I was dealing with an AJAX application/RIA, I was having the same issue! And I used implicit wait, with a time of around 90 seconds. It waits, till the element is available...So, what we can do to make sure, that page gets loaded completely is,
add a boolean statement, checking for whether the condition(a particular part of the element), is present and assign it to a variable, check for the condition and only when it is true, " do the necessary actions!"...In this way, I figured out, both waits could be used...
Ex:
@Before
{ implicit wait statement}
@Test
{
boolean tr1=Driver.findElement(By.xpath("xx")).isEnabled/isDisplayed;
if (tr1==true && ____)//as many conditions, to make sure, the page is loaded
{
//do the necessary set of actions...
driver.findElement(By.xpath("yy")).click();
}
}
Hope this helps!! It is in implementation stage, for me too...