From d4f596426f62b7ae3ec5893584a49db0b7245240 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Thu, 6 Jun 2024 16:31:29 +0530 Subject: [PATCH] Add preference to enable CDP in Firefox by default Related to #11736 --- dotnet/src/webdriver/Firefox/FirefoxOptions.cs | 3 +++ java/src/org/openqa/selenium/firefox/FirefoxOptions.java | 4 ++++ javascript/node/selenium-webdriver/firefox.js | 3 +++ py/selenium/webdriver/firefox/options.py | 3 +++ rb/lib/selenium/webdriver/firefox/options.rb | 3 +++ 5 files changed, 16 insertions(+) diff --git a/dotnet/src/webdriver/Firefox/FirefoxOptions.cs b/dotnet/src/webdriver/Firefox/FirefoxOptions.cs index a5c8c0a5d494e3..6b74548096ed67 100644 --- a/dotnet/src/webdriver/Firefox/FirefoxOptions.cs +++ b/dotnet/src/webdriver/Firefox/FirefoxOptions.cs @@ -88,6 +88,9 @@ public FirefoxOptions() this.AddKnownCapabilityName(FirefoxOptions.FirefoxLegacyProfileCapability, "Profile property"); this.AddKnownCapabilityName(FirefoxOptions.FirefoxLegacyBinaryCapability, "BrowserExecutableLocation property"); this.AddKnownCapabilityName(FirefoxOptions.FirefoxEnableDevToolsProtocolCapability, "EnableDevToolsProtocol property"); + // Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it. + // https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/. + this.SetPreference("remote.active-protocols", 2); } /// diff --git a/java/src/org/openqa/selenium/firefox/FirefoxOptions.java b/java/src/org/openqa/selenium/firefox/FirefoxOptions.java index ddde5e5402c51e..15937b5a8a32cc 100644 --- a/java/src/org/openqa/selenium/firefox/FirefoxOptions.java +++ b/java/src/org/openqa/selenium/firefox/FirefoxOptions.java @@ -63,6 +63,10 @@ public FirefoxOptions() { setCapability(CapabilityType.BROWSER_NAME, FIREFOX.browserName()); setAcceptInsecureCerts(true); setCapability("moz:debuggerAddress", true); + // Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference + // will enable it. + // https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/. + addPreference("remote.active-protocols", 2); } public FirefoxOptions(Capabilities source) { diff --git a/javascript/node/selenium-webdriver/firefox.js b/javascript/node/selenium-webdriver/firefox.js index d3fd0c60e92800..20883116a8f122 100644 --- a/javascript/node/selenium-webdriver/firefox.js +++ b/javascript/node/selenium-webdriver/firefox.js @@ -246,6 +246,9 @@ class Options extends Capabilities { constructor(other) { super(other) this.setBrowserName(Browser.FIREFOX) + // Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it. + // https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/. + this.setPreference('remote.active-protocols', 2) } /** diff --git a/py/selenium/webdriver/firefox/options.py b/py/selenium/webdriver/firefox/options.py index 1cb3a2bdd08a49..7d75f52c35d6a9 100644 --- a/py/selenium/webdriver/firefox/options.py +++ b/py/selenium/webdriver/firefox/options.py @@ -41,6 +41,9 @@ def __init__(self) -> None: super().__init__() self._binary_location = "" self._preferences: dict = {} + # Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it. + # https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/. + self._preferences["remote.active-protocols"] = 2 self._profile = None self.log = Log() diff --git a/rb/lib/selenium/webdriver/firefox/options.rb b/rb/lib/selenium/webdriver/firefox/options.rb index 23a9014ba12b0d..61d830489cfcfb 100644 --- a/rb/lib/selenium/webdriver/firefox/options.rb +++ b/rb/lib/selenium/webdriver/firefox/options.rb @@ -64,6 +64,9 @@ def initialize(log_level: nil, **opts) @options[:args] ||= [] @options[:prefs] ||= {} + # Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it. + # https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/. + @options[:prefs]['remote.active-protocols'] = 2 @options[:env] ||= {} @options[:log] ||= {level: log_level} if log_level