Description
As noted in this GitHub comment, we introduced a regression in our wait for navigation to complete
algorithm, which causes timeouts to be mishandled when a user prompt is opened. The missing sentence from the original specification is:
If the previous step completed by the session page load timeout being reached and the browser does not have an active user prompt, return error with error code timeout.
Currently, this causes the navigation to always timeout.
In addition to restoring this behavior, I’m questioning why we need to wait for a timeout before checking for user prompts. While beforeunload
prompts are automatically dismissed in WebDriver classic, we don’t do this for other prompt types like alert
, confirm
, and prompt
. This results in a timeout delay, which defaults to 300 seconds! Why can't we simply return from the navigation as soon as a user prompt is opened?
Here’s a basic example of a page that would cause a timeout:
<script>
window.alert("test");
</script>
Additional thoughts:
- All major browsers currently detect user prompts the moment they appear, causing the navigation to return immediately.
- We may want this behavior to apply to all commands, which would require a more general handling mechanism.
- We need to ensure that this change does not introduce any new regressions or create incompatibility with WebDriver BiDi.