How I can check whether a page is loaded completely or not in web driver?

前端 未结 9 1836
走了就别回头了
走了就别回头了 2020-12-01 01:33

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

9条回答
  •  再見小時候
    2020-12-01 02:04

    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...

提交回复
热议问题