From f0fdb9e5d28c4c2e94e7b30745dca281092d8dac Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Tue, 27 Aug 2024 11:32:27 +0530 Subject: [PATCH] [java][js] Fixing prompt/alert related tests if BiDi is enabled --- java/test/org/openqa/selenium/testing/drivers/Browser.java | 5 +++++ .../node/selenium-webdriver/bidi/browsingContextInspector.js | 4 ++-- javascript/node/selenium-webdriver/testing/index.js | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/java/test/org/openqa/selenium/testing/drivers/Browser.java b/java/test/org/openqa/selenium/testing/drivers/Browser.java index 0675dbe04b32b..9b2ddfb2e5a4d 100644 --- a/java/test/org/openqa/selenium/testing/drivers/Browser.java +++ b/java/test/org/openqa/selenium/testing/drivers/Browser.java @@ -18,6 +18,7 @@ package org.openqa.selenium.testing.drivers; import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME; +import static org.openqa.selenium.remote.CapabilityType.UNHANDLED_PROMPT_BEHAVIOUR; import java.util.HashMap; import java.util.Map; @@ -61,6 +62,9 @@ public Capabilities getCapabilities() { options.enableBiDi(); + // Reason: https://github.com/SeleniumHQ/selenium/pull/14429#issuecomment-2311614822 + options.setCapability(UNHANDLED_PROMPT_BEHAVIOUR, "ignore"); + return options; } }, @@ -91,6 +95,7 @@ public Capabilities getCapabilities() { options.setExperimentalOption("prefs", prefs); options.enableBiDi(); + options.setCapability(UNHANDLED_PROMPT_BEHAVIOUR, "ignore"); return options; } diff --git a/javascript/node/selenium-webdriver/bidi/browsingContextInspector.js b/javascript/node/selenium-webdriver/bidi/browsingContextInspector.js index b6bcecf70decf..e4d1725782a82 100644 --- a/javascript/node/selenium-webdriver/bidi/browsingContextInspector.js +++ b/javascript/node/selenium-webdriver/bidi/browsingContextInspector.js @@ -127,10 +127,10 @@ class BrowsingContextInspector { let response = null if ('navigation' in params) { response = new NavigationInfo(params.context, params.navigation, params.timestamp, params.url) - } else if ('type' in params) { - response = new UserPromptOpened(params.context, params.type, params.message) } else if ('accepted' in params) { response = new UserPromptClosed(params.context, params.accepted, params.userText) + } else if ('type' in params) { + response = new UserPromptOpened(params.context, params.type, params.message) } else { response = new BrowsingContextInfo(params.context, params.url, params.children, params.parent) } diff --git a/javascript/node/selenium-webdriver/testing/index.js b/javascript/node/selenium-webdriver/testing/index.js index c96f18d453592..d48bb4affd9f8 100644 --- a/javascript/node/selenium-webdriver/testing/index.js +++ b/javascript/node/selenium-webdriver/testing/index.js @@ -346,6 +346,7 @@ class Environment { // Enable BiDi for supporting browsers. if (browser.name === Browser.FIREFOX || browser.name === Browser.CHROME || browser.name === Browser.EDGE) { builder.setCapability('webSocketUrl', true) + builder.setCapability('unhandledPromptBehavior', 'ignore') } if (typeof urlOrServer === 'string') {