Elen Elen - 2 months ago 26
R Question

Document complete in RSelenium

Instead of using:

Sys.sleep(5)


to wait the dom to load is there any wait to wait until this command

document.readyState


give result
"complete"
so the dom is ready

Answer

Selenium already implements polling of the document.readyState via the timeouts set of methods. RSelenium has the setTimeout methods. Increasing the timeout for page load should result in Selenium allowing more time for the operation to complete.

The problem comes when webpages don't finish loading. Some webpage are continuously loading calling themselves with delay. In this case you can check for the presence of an element in the DOM for example.

See

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

and

Selenium WebDriver : Wait for complex page with JavaScript(JS) to load

for further discussion. With RSelenium you can of course run JavaScript e.g.

remDr$executeScript("return document.readyState == 'complete';")

For modern webpages the issue of detecting when a page load is deemed to have completed can be problematic and solutions case specific.