Closed BhavikaTibrewal closed 1 week ago
Thanks for the report. After taking a look I don't see any related code that uses readyState
to check the loading state of the document. Can you please clarify where it should exactly be used? Maybe you missed something. We have tests running in CI that exactly check for the correct state. So we would need a trace log that actually shows the issue.
Or what does loading state mean? Note that additional content can be loaded by the page via fetch etc. after it reached the complete
state. So maybe that's what you experiencing here?
Here loading state is the resolving state of the browser which is the reverse loading state of the web page in which it fetched the document of the page ( will update with more details related to this)
Code that check for document.readystate
page.execute
has this code behind it
async waitForDocumetReadyState(timelimit) {
const timeoutPromise = new Promise((resolve) => {
setTimeout(() => {
resolve({ status: 0, message: 'timedout' });
}, timelimit);
});
let result = await Promise.race([
this.page.execute(async function () {
async function checkDocumentReadyState() {
return new Promise(resolve => {
function check() {
if (document.readyState === 'complete') {
console.log('Document is ready!');
resolve();
} else {
console.log('Document is still loading...');
setTimeout(check, 100);
}
}
check();
});
};
try {
await checkDocumentReadyState();
return true;
} catch (error) {
return false;
};
}),
timeoutPromise
]);
return result;
}
So if the readyState
is not complete
at the time when the script gets executed it could happen that due to a process change the command returns. This is expected but not yet exactly clarified in the WebDriver classic specification. There is a change in Firefox Nightly that landed last night, which under such a situation also returns a failure, so that client code can try to re-run the script. But nevertheless why aren't you using the pageLoadStrategy
set to complete
which will trigger the browser to wait on its own?
But regarding the above problem the provided trace log doesn't show any instance of a document.readyState
usage, and as such I cannot blindly say what's wrong. So please try again and provide a log where this line is in the log.
Due to the lack of response I'm going ahead and close the issue, but I'm happy to reopen if the requested information is given and indicates that this is a bug.
System
Description
In chrome we see the code waits at
page.execute
for the page loading state to resolve and then proceeds but in case of Firefox the code proceed even when the browser is still in loading state as we gotdocument.readyState === "complete"
Testcase
Stacktrace
Trace-level log