diff --git a/src/bidiMapper/modules/context/BrowsingContextImpl.ts b/src/bidiMapper/modules/context/BrowsingContextImpl.ts index a9957a46da..c59a17118d 100644 --- a/src/bidiMapper/modules/context/BrowsingContextImpl.ts +++ b/src/bidiMapper/modules/context/BrowsingContextImpl.ts @@ -712,6 +712,7 @@ export class BrowsingContextImpl { case BrowsingContext.UserPromptType.Beforeunload: return ( this.#unhandledPromptBehavior?.beforeUnload ?? + this.#unhandledPromptBehavior?.default ?? // In WebDriver Classic spec, `beforeUnload` prompt should be accepted by // default. Step 4 of "Get the prompt handler" algorithm // (https://w3c.github.io/webdriver/#dfn-get-the-prompt-handler): diff --git a/tests/browsing_context/test_user_prompt.py b/tests/browsing_context/test_user_prompt.py index 3bcc96a16c..14748b6a17 100644 --- a/tests/browsing_context/test_user_prompt.py +++ b/tests/browsing_context/test_user_prompt.py @@ -249,6 +249,16 @@ async def test_browsingContext_beforeUnloadPromptOpened_capabilityRespected( if 'beforeUnload' in capabilities['unhandledPromptBehavior']: expected_handler = capabilities['unhandledPromptBehavior'][ 'beforeUnload'] + elif 'default' in capabilities['unhandledPromptBehavior']: + expected_handler = capabilities['unhandledPromptBehavior'][ + 'default'] + if isinstance(capabilities['unhandledPromptBehavior'], str): + if capabilities[ + 'unhandledPromptBehavior'] == 'dismiss' or capabilities[ + 'unhandledPromptBehavior'] == 'dismiss and notify': + expected_handler = 'dismiss' + elif capabilities['unhandledPromptBehavior'] == 'ignore': + expected_handler = 'ignore' resp = await read_JSON_message(websocket) assert resp == {