how to check if page finished loading in RSelenium how to check if page finished loading in RSelenium selenium selenium

how to check if page finished loading in RSelenium


Set ImplicitWaitTimeout and then search for an element on the page. From ?remoteDriver

setImplicitWaitTimeout(milliseconds = 10000)

Set the amount of timethe driver should wait when searching for elements. When searching fora single element, the driver will poll the page until an element isfound or the timeout expires, whichever occurs first. When searchingfor multiple elements, the driver should poll the page until at leastone element is found or the timeout expires, at which point it willreturn an empty list. If this method is never called, the driver willdefault to an implicit wait of 0ms.


In the RSelenium reference manual (http://cran.r-project.org/web/packages/RSelenium/RSelenium.pdf), you will find the method setTimeout() for the remoteDriver class:

setTimeout(type = "page load", milliseconds = 10000)

Configure the amount of time that a particular type of operation can execute for before they are aborted and a |Timeout| error is returned to the client.

type: The type of operation to set the timeout for. Valid values are: "script" for script timeouts, "implicit" for modifying the implicit wait timeout and "page load" for setting a page load timeout. Defaults to "page load"

milliseconds: The amount of time, in milliseconds, that time-limited commands are permitted to run. Defaults to 10000 milliseconds.

This seems to suggests that remDr$setTimeout() after remDr$navigate("...") would actually wait for the page to load, or return a timeout error after 10 seconds.


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.