how to check if page finished loading in RSelenium

后端 未结 3 618
我寻月下人不归
我寻月下人不归 2021-01-13 05:36

Imagine that you click on an element using RSelenium on a page and would like to retrieve the results from the resulting page. How does one check to make sure t

3条回答
  •  梦毁少年i
    2021-01-13 05:59

    you can also try out this code that waits for the browser to provide whether page loaded or not.

    objExecutor = (JavascriptExecutor) objDriver;
    if (!objExecutor.executeScript("return document.readyState").toString()
        .equalsIgnoreCase("complete")){
        Thread.sleep(1000);
    }
    

    You can simply put it in your base page so you wont need to write it down in every pageobjects. I have never tried it out with any AJAX enabled sites, but this might help you and your scenario dependency will also get away.

提交回复
热议问题