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
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
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.
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