Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Synthetics - scripted browser .Use document.readyState to ensure a website was fully loaded


Hi ,
When using scripted browser in Synthetics, I tried to execute document.readyState and got ‘ReferenceError: document is not defined’
Any idea ?


Hi @NOC23 - Have you any more information? Any pseudo-code for your script? Are you executing document.readyState from the synthetic directly or using $browser.executeScript instead?


That document.getElementById must run in the browser; it is not part of the WebDriverJS framework. If you let me know what actions you are trying to perform I can suggest an alternative :slight_smile:


Hi ,
I need to check if the page was fully loaded (using readyState )



document.readyState will report complete just before the page load event is emitted.

The page load event is something we already check for in Synthetic Browser monitors. If the page load event is not observed in 60s, we fail the monitor check with a Page Load Timeout error.

In any case, since document.readyState is only available in the page context, you can use the $browser.executeScript() method to execute JS in the page context as @stefan_garnham mentioned above.

And wrap it, in a $browser.wait() condition to wait for the complete state.