Instead of using:
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.
for further discussion. With
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.