Any idea why I.waitUntil(() => window.document.readyState === 'complete');
fails with window is not defined
?
original from @davert
it is executed on server side…
use executeAsync script for that or
const pageLoaded = browser =>
browser.waitUntil(async () => {
const state = await browser.execute('return document.readyState');
return state === 'complete';
}, 15000, 'Page load timed out!', 2500);
cool, thanks, I added this to the actor:
waitForDocumentStateComplete: function() {
this.executeAsyncScript(function(done) {
const interval = setInterval(function() {
if (window.document.readyState === 'complete') {
clearInterval(interval);
done();
}
}, 100);
});
}
and could use it as I.waitForDocumentStateComplete()
I’m using I.waitForFunction(() => document.readyState == "complete", 10);
in one of my page objects. It was an attempt to wait for page content after reload of browser.
Not sure it really works, but I know it doesn’t fail at least
1 Like
cool thanks for the reminder, should do the same