Skip to content

Commit febd025

Browse files
pujaganisandeepsuryaprasad
authored andcommitted
Add preference to enable CDP in Firefox by default (SeleniumHQ#14091)
Related to SeleniumHQ#11736
1 parent d866903 commit febd025

File tree

11 files changed

+84
-10
lines changed

11 files changed

+84
-10
lines changed

dotnet/src/webdriver/Firefox/FirefoxOptions.cs

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public FirefoxOptions()
8888
this.AddKnownCapabilityName(FirefoxOptions.FirefoxLegacyProfileCapability, "Profile property");
8989
this.AddKnownCapabilityName(FirefoxOptions.FirefoxLegacyBinaryCapability, "BrowserExecutableLocation property");
9090
this.AddKnownCapabilityName(FirefoxOptions.FirefoxEnableDevToolsProtocolCapability, "EnableDevToolsProtocol property");
91+
// Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it.
92+
// https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/.
93+
this.SetPreference("remote.active-protocols", 3);
9194
}
9295

9396
/// <summary>

java/.idea/workspace.xml

+49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/src/org/openqa/selenium/firefox/FirefoxOptions.java

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public FirefoxOptions() {
6363
setCapability(CapabilityType.BROWSER_NAME, FIREFOX.browserName());
6464
setAcceptInsecureCerts(true);
6565
setCapability("moz:debuggerAddress", true);
66+
// Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference
67+
// will enable it.
68+
// https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/.
69+
addPreference("remote.active-protocols", 3);
6670
}
6771

6872
public FirefoxOptions(Capabilities source) {

javascript/node/selenium-webdriver/firefox.js

+3
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ class Options extends Capabilities {
246246
constructor(other) {
247247
super(other)
248248
this.setBrowserName(Browser.FIREFOX)
249+
// Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it.
250+
// https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/.
251+
this.setPreference('remote.active-protocols', 3)
249252
}
250253

251254
/**

javascript/node/selenium-webdriver/test/firefox/options_test.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ suite(
8787
it('allows setting android activity', function () {
8888
let options = new firefox.Options().enableMobile()
8989
let firefoxOptions = options.firefoxOptions_()
90-
assert.deepStrictEqual({ androidPackage: 'org.mozilla.firefox' }, firefoxOptions)
90+
assert.deepStrictEqual(
91+
{
92+
androidPackage: 'org.mozilla.firefox',
93+
prefs: { 'remote.active-protocols': 3 },
94+
},
95+
firefoxOptions,
96+
)
9197
})
9298
})
9399

py/selenium/webdriver/firefox/options.py

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ def __init__(self) -> None:
4141
super().__init__()
4242
self._binary_location = ""
4343
self._preferences: dict = {}
44+
# Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it.
45+
# https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/.
46+
self._preferences["remote.active-protocols"] = 3
4447
self._profile = None
4548
self.log = Log()
4649

py/test/unit/selenium/webdriver/firefox/firefox_options_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_set_proxy_isnt_in_moz_prefix(options):
7979

8080
caps = options.to_capabilities()
8181
assert caps["proxy"]["proxyType"] == "manual"
82-
assert caps.get("moz:firefoxOptions") is None
82+
assert caps.get("moz:firefoxOptions") == {"prefs": {"remote.active-protocols": 3}}
8383

8484

8585
def test_raises_exception_if_proxy_is_not_proxy_object(options):

py/test/unit/selenium/webdriver/remote/new_session_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_works_as_context_manager(mocker):
5252

5353

5454
@pytest.mark.parametrize("browser_name", ["firefox", "chrome", "ie"])
55-
def test_accepts_options_to_remote_driver(mocker, browser_name):
55+
def test_acepts_options_to_remote_driver(mocker, browser_name):
5656
options = import_module(f"selenium.webdriver.{browser_name}.options")
5757
mock = mocker.patch("selenium.webdriver.remote.webdriver.WebDriver.start_session")
5858

@@ -103,7 +103,7 @@ def test_first_match_when_2_different_option_types():
103103
"browserName": "firefox",
104104
"acceptInsecureCerts": True,
105105
"moz:debuggerAddress": True,
106-
"moz:firefoxOptions": {"args": ["foo"]},
106+
"moz:firefoxOptions": {"args": ["foo"], "prefs": {"remote.active-protocols": 3}},
107107
},
108108
],
109109
}

rb/lib/selenium/webdriver/firefox/options.rb

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def initialize(log_level: nil, **opts)
6464

6565
@options[:args] ||= []
6666
@options[:prefs] ||= {}
67+
# Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it.
68+
# https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/.
69+
@options[:prefs]['remote.active-protocols'] = 3
6770
@options[:env] ||= {}
6871
@options[:log] ||= {level: log_level} if log_level
6972

rb/spec/unit/selenium/webdriver/firefox/driver_spec.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module Firefox
3838
def expect_request(body: nil, endpoint: nil)
3939
body = (body || {capabilities: {alwaysMatch: {acceptInsecureCerts: true,
4040
browserName: 'firefox',
41-
'moz:firefoxOptions': {},
41+
'moz:firefoxOptions': {prefs: {'remote.active-protocols' => 3}},
4242
'moz:debuggerAddress': true}}}).to_json
4343
endpoint ||= "#{service_manager.uri}/session"
4444
stub_request(:post, endpoint).with(body: body).to_return(valid_response)
@@ -79,7 +79,10 @@ def expect_request(body: nil, endpoint: nil)
7979
opts = {args: ['-f']}
8080
expect_request(body: {capabilities: {alwaysMatch: {acceptInsecureCerts: true,
8181
browserName: 'firefox',
82-
'moz:firefoxOptions': opts,
82+
'moz:firefoxOptions': {
83+
args: ['-f'],
84+
prefs: {'remote.active-protocols' => 3}
85+
},
8386
'moz:debuggerAddress': true}}})
8487
expect { described_class.new(options: Options.new(**opts)) }.not_to raise_exception
8588
end

rb/spec/unit/selenium/webdriver/firefox/options_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ module Firefox
154154
options.add_preference('intl.accepted_languages', 'en-US')
155155

156156
prefs = options.as_json['moz:firefoxOptions']['prefs']
157-
expected = {'intl.accepted_languages' => 'en-US'}
157+
expected = {'intl.accepted_languages' => 'en-US', 'remote.active-protocols' => 3}
158158
expect(prefs).to eq(expected)
159159
end
160160
end
@@ -185,7 +185,7 @@ module Firefox
185185
it 'returns empty options by default' do
186186
expect(options.as_json).to eq('browserName' => 'firefox',
187187
'acceptInsecureCerts' => true,
188-
'moz:firefoxOptions' => {},
188+
'moz:firefoxOptions' => {'prefs' => {'remote.active-protocols' => 3}},
189189
'moz:debuggerAddress' => true)
190190
end
191191

@@ -195,7 +195,7 @@ module Firefox
195195
'browserName' => 'firefox',
196196
'foo:bar' => {'foo' => 'bar'},
197197
'moz:debuggerAddress' => true,
198-
'moz:firefoxOptions' => {})
198+
'moz:firefoxOptions' => {'prefs' => {'remote.active-protocols' => 3}})
199199
end
200200

201201
it 'converts to a json hash' do
@@ -240,7 +240,7 @@ module Firefox
240240
'moz:debuggerAddress' => true,
241241
key => {'args' => %w[foo bar],
242242
'binary' => '/foo/bar',
243-
'prefs' => {'foo' => 'bar'},
243+
'prefs' => {'foo' => 'bar', 'remote.active-protocols' => 3},
244244
'env' => {'FOO' => 'bar'},
245245
'profile' => 'encoded_profile',
246246
'log' => {'level' => 'debug'},

0 commit comments

Comments
 (0)