From a9bd7ee3b605d46ce8e8e2fb95e1cc897fe393cc Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Fri, 31 Jan 2025 13:52:53 +0530 Subject: [PATCH 01/14] [java] Remove Firefox CDP support --- .../selenium/firefox/FirefoxDriver.java | 100 +----------------- 1 file changed, 4 insertions(+), 96 deletions(-) diff --git a/java/src/org/openqa/selenium/firefox/FirefoxDriver.java b/java/src/org/openqa/selenium/firefox/FirefoxDriver.java index 9d48f66fbab85..392e106037358 100644 --- a/java/src/org/openqa/selenium/firefox/FirefoxDriver.java +++ b/java/src/org/openqa/selenium/firefox/FirefoxDriver.java @@ -78,7 +78,7 @@ * */ public class FirefoxDriver extends RemoteWebDriver - implements WebStorage, HasExtensions, HasFullPageScreenshot, HasContext, HasDevTools, HasBiDi { + implements WebStorage, HasExtensions, HasFullPageScreenshot, HasContext, HasBiDi { private static final Logger LOG = Logger.getLogger(FirefoxDriver.class.getName()); private final Capabilities capabilities; @@ -86,10 +86,7 @@ public class FirefoxDriver extends RemoteWebDriver private final HasExtensions extensions; private final HasFullPageScreenshot fullPageScreenshot; private final HasContext context; - private final Optional cdpUri; private final Optional biDiUri; - private Connection connection; - private DevTools devTools; private final Optional biDi; /** @@ -160,42 +157,7 @@ private FirefoxDriver( context = new AddHasContext().getImplementation(getCapabilities(), getExecuteMethod()); Capabilities capabilities = super.getCapabilities(); - HttpClient.Factory factory = HttpClient.Factory.createDefault(); - - Optional reportedUri = - CdpEndpointFinder.getReportedUri("moz:debuggerAddress", capabilities); - - if (reportedUri.isPresent() && !capabilities.is("webSocketUrl")) { - LOG.warning( - "CDP support for Firefox is deprecated and will be removed in future versions. " - + "Please switch to WebDriver BiDi."); - } - - Optional client = - reportedUri.map(uri -> CdpEndpointFinder.getHttpClient(factory, uri)); - Optional cdpUri; - - try { - cdpUri = client.flatMap(CdpEndpointFinder::getCdpEndPoint); - } catch (Exception e) { - try { - client.ifPresent(HttpClient::close); - } catch (Exception ex) { - e.addSuppressed(ex); - } - throw e; - } - - try { - client.ifPresent(HttpClient::close); - } catch (Exception e) { - LOG.log( - Level.FINE, - "failed to close the http client used to check the reported CDP endpoint: " - + reportedUri.get(), - e); - } - + Optional webSocketUrl = Optional.ofNullable((String) capabilities.getCapability("webSocketUrl")); @@ -212,16 +174,7 @@ private FirefoxDriver( this.biDi = createBiDi(biDiUri); - this.cdpUri = cdpUri; - this.capabilities = - cdpUri - .map( - uri -> - new ImmutableCapabilities( - new PersistentCapabilities(capabilities) - .setCapability("se:cdp", uri.toString()) - .setCapability("se:cdpVersion", "85.0"))) - .orElse(new ImmutableCapabilities(capabilities)); + this.capabilities = new ImmutableCapabilities(capabilities); } @Beta @@ -314,52 +267,7 @@ public void setContext(FirefoxCommandContext commandContext) { Require.nonNull("Firefox Command Context", commandContext); context.setContext(commandContext); } - - /** - * @deprecated Use W3C-compliant BiDi protocol. Use {{@link #maybeGetBiDi()}} - */ - @Deprecated - @Override - public Optional maybeGetDevTools() { - if (devTools != null) { - return Optional.of(devTools); - } - - if (!cdpUri.isPresent()) { - return Optional.empty(); - } - - URI wsUri = - cdpUri.orElseThrow( - () -> - new DevToolsException( - "This version of Firefox or geckodriver does not support CDP")); - HttpClient.Factory clientFactory = HttpClient.Factory.createDefault(); - - ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri); - HttpClient wsClient = clientFactory.createClient(wsConfig); - - connection = new Connection(wsClient, wsUri.toString()); - CdpInfo cdpInfo = new CdpVersionFinder().match("85.0").orElseGet(NoOpCdpInfo::new); - devTools = new DevTools(cdpInfo::getDomains, connection); - - return Optional.of(devTools); - } - - /** - * @deprecated Use W3C-compliant BiDi protocol. Use {{@link #getBiDi()}} - */ - @Deprecated - @Override - public DevTools getDevTools() { - if (!cdpUri.isPresent()) { - throw new DevToolsException("This version of Firefox or geckodriver does not support CDP"); - } - - return maybeGetDevTools() - .orElseThrow(() -> new DevToolsException("Unable to initialize CDP connection")); - } - + private Optional createBiDi(Optional biDiUri) { if (biDiUri.isEmpty()) { return Optional.empty(); From a3f69b33a5f110e1ee1ffc7646fae158ea243e16 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Fri, 31 Jan 2025 14:08:18 +0530 Subject: [PATCH 02/14] [js] Remove Firefox CDP support --- javascript/node/selenium-webdriver/lib/webdriver.js | 5 ++--- javascript/node/selenium-webdriver/test/devtools_test.js | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/javascript/node/selenium-webdriver/lib/webdriver.js b/javascript/node/selenium-webdriver/lib/webdriver.js index f80875cf6b63e..c2b1b2db1d4b3 100644 --- a/javascript/node/selenium-webdriver/lib/webdriver.js +++ b/javascript/node/selenium-webdriver/lib/webdriver.js @@ -1244,8 +1244,8 @@ class WebDriver { const caps = await this.getCapabilities() if (caps['map_'].get('browserName') === 'firefox') { - console.warn( - 'CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.', + throw new Error( + 'CDP support for Firefox is removed. Please switch to WebDriver BiDi.', ) } @@ -1258,7 +1258,6 @@ class WebDriver { const vendorInfo = caps['map_'].get('goog:chromeOptions') || caps['map_'].get('ms:edgeOptions') || - caps['map_'].get('moz:debuggerAddress') || new Map() debuggerUrl = seCdp || vendorInfo['debuggerAddress'] || vendorInfo } diff --git a/javascript/node/selenium-webdriver/test/devtools_test.js b/javascript/node/selenium-webdriver/test/devtools_test.js index 701f0395a5d2c..f287d7790b43f 100644 --- a/javascript/node/selenium-webdriver/test/devtools_test.js +++ b/javascript/node/selenium-webdriver/test/devtools_test.js @@ -91,7 +91,7 @@ suite( }) describe('Basic Auth Injection', function () { - ignore(browsers(Browser.SAFARI, Browser.FIREFOX, Browser.CHROME)).it( + ignore(browsers(Browser.SAFARI, Browser.CHROME)).it( 'denies entry if username and password do not match', async function () { const pageCdpConnection = await driver.createCDPConnection('page') @@ -103,7 +103,7 @@ suite( }, ) - ignore(browsers(Browser.SAFARI, Browser.FIREFOX, Browser.CHROME)).it( + ignore(browsers(Browser.SAFARI, Browser.CHROME)).it( 'grants access if username and password are a match', async function () { const pageCdpConnection = await driver.createCDPConnection('page') @@ -117,7 +117,7 @@ suite( }) describe('Network Interception', function () { - ignore(browsers(Browser.SAFARI, Browser.FIREFOX)).it( + ignore(browsers(Browser.SAFARI).it( 'Allows network requests to be captured and mocked', async function () { const connection = await driver.createCDPConnection('page') @@ -134,5 +134,5 @@ suite( ) }) }, - { browsers: ['firefox', 'chrome'] }, + { browsers: ['chrome'] }, ) From 496a15897f2762b35a92863cc0cec5f83526eae1 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Fri, 31 Jan 2025 14:10:44 +0530 Subject: [PATCH 03/14] [js] Fix formatting --- javascript/node/selenium-webdriver/test/devtools_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/node/selenium-webdriver/test/devtools_test.js b/javascript/node/selenium-webdriver/test/devtools_test.js index f287d7790b43f..4f3697202495a 100644 --- a/javascript/node/selenium-webdriver/test/devtools_test.js +++ b/javascript/node/selenium-webdriver/test/devtools_test.js @@ -131,7 +131,7 @@ suite( }) await driver.get(url) }, - ) + )) }) }, { browsers: ['chrome'] }, From b2b8389fe6678af0760091b844832a46ffa3127d Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Fri, 31 Jan 2025 14:29:40 +0530 Subject: [PATCH 04/14] [rb] Remove Firefox CDP support --- rb/lib/selenium/webdriver/firefox/driver.rb | 18 ------------ .../lib/selenium/webdriver/firefox/driver.rbs | 6 ---- .../selenium/webdriver/devtools_spec.rb | 29 +++++++------------ 3 files changed, 10 insertions(+), 43 deletions(-) diff --git a/rb/lib/selenium/webdriver/firefox/driver.rb b/rb/lib/selenium/webdriver/firefox/driver.rb index 717eea5ba711c..b2133c18898f8 100644 --- a/rb/lib/selenium/webdriver/firefox/driver.rb +++ b/rb/lib/selenium/webdriver/firefox/driver.rb @@ -30,7 +30,6 @@ class Driver < WebDriver::Driver DriverExtensions::FullPageScreenshot, DriverExtensions::HasContext, DriverExtensions::HasBiDi, - DriverExtensions::HasDevTools, DriverExtensions::HasLogEvents, DriverExtensions::HasNetworkInterception, DriverExtensions::HasWebStorage, @@ -46,23 +45,6 @@ def initialize(options: nil, service: nil, url: nil, **opts) def browser :firefox end - - private - - def devtools_url - if capabilities['moz:debuggerAddress'].nil? - raise(Error::WebDriverError, 'DevTools is not supported by this version of Firefox; use v85 or higher') - end - - uri = URI("http://#{capabilities['moz:debuggerAddress']}") - response = Net::HTTP.get(uri.hostname, '/json/version', uri.port) - - JSON.parse(response)['webSocketDebuggerUrl'] - end - - def devtools_version - Firefox::DEVTOOLS_VERSION - end end # Driver end # Firefox end # WebDriver diff --git a/rb/sig/lib/selenium/webdriver/firefox/driver.rbs b/rb/sig/lib/selenium/webdriver/firefox/driver.rbs index 7dd993e287aaf..06484a1f13cfa 100644 --- a/rb/sig/lib/selenium/webdriver/firefox/driver.rbs +++ b/rb/sig/lib/selenium/webdriver/firefox/driver.rbs @@ -9,12 +9,6 @@ module Selenium def initialize: (?options: untyped?, ?service: untyped?, ?url: untyped?, **untyped opts) -> void def browser: () -> Symbol - - private - - def devtools_url: () -> untyped - - def devtools_version: () -> untyped end end end diff --git a/rb/spec/integration/selenium/webdriver/devtools_spec.rb b/rb/spec/integration/selenium/webdriver/devtools_spec.rb index 64e03e0851641..b8bdd29f44684 100644 --- a/rb/spec/integration/selenium/webdriver/devtools_spec.rb +++ b/rb/spec/integration/selenium/webdriver/devtools_spec.rb @@ -22,7 +22,7 @@ module Selenium module WebDriver describe DevTools, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, - {browser: %i[chrome edge firefox]}] do + {browser: %i[chrome edge]}] do after { |example| reset_driver!(example: example) } it 'sends commands' do @@ -36,8 +36,7 @@ module WebDriver expect(driver.devtools.dom_debugger).not_to be_nil end - it 'supports events', except: {browser: :firefox, - reason: 'https://bugzilla.mozilla.org/show_bug.cgi?id=1819965'} do + it 'supports events' do expect { |block| driver.devtools.page.enable driver.devtools.page.on(:load_event_fired, &block) @@ -46,8 +45,7 @@ module WebDriver }.to yield_control end - it 'propagates errors in events', except: {browser: :firefox, - reason: 'https://bugzilla.mozilla.org/show_bug.cgi?id=1819965'} do + it 'propagates errors in events' do expect { driver.devtools.page.enable driver.devtools.page.on(:load_event_fired) { raise 'This is fine!' } @@ -56,8 +54,7 @@ module WebDriver }.to raise_error(RuntimeError, 'This is fine!') end - describe '#register', except: {browser: :firefox, - reason: 'Fetch.enable is not yet supported'} do + describe '#register' do let(:username) { SpecSupport::RackServer::TestApp::BASIC_AUTH_CREDENTIALS.first } let(:password) { SpecSupport::RackServer::TestApp::BASIC_AUTH_CREDENTIALS.last } @@ -80,8 +77,7 @@ module WebDriver end end - it 'notifies about log messages', except: {browser: :firefox, - reason: 'https://bugzilla.mozilla.org/show_bug.cgi?id=1819965'} do + it 'notifies about log messages' do logs = [] driver.on_log_event(:console) { |log| logs.push(log) } driver.navigate.to url_for('javascriptPage.html') @@ -105,8 +101,7 @@ module WebDriver ) end - it 'notifies about document log messages', except: {browser: :firefox, - reason: 'Firefox & Chrome parse document differently'} do + it 'notifies about document log messages' do logs = [] driver.on_log_event(:console) { |log| logs.push(log) } driver.navigate.to url_for('javascriptPage.html') @@ -119,8 +114,7 @@ module WebDriver ) end - it 'notifies about document log messages', - except: {browser: %i[chrome edge firefox], reason: 'https://bugzilla.mozilla.org/show_bug.cgi?id=1819965'} do + it 'notifies about document log messages' do logs = [] driver.on_log_event(:console) { |log| logs.push(log) } driver.navigate.to url_for('javascriptPage.html') @@ -133,8 +127,7 @@ module WebDriver ) end - it 'notifies about exceptions', except: {browser: :firefox, - reason: 'https://bugzilla.mozilla.org/show_bug.cgi?id=1819965'} do + it 'notifies about exceptions' do exceptions = [] driver.on_log_event(:exception) { |exception| exceptions.push(exception) } driver.navigate.to url_for('javascriptPage.html') @@ -147,8 +140,7 @@ module WebDriver expect(exception.stacktrace).not_to be_empty end - it 'notifies about DOM mutations', except: {browser: :firefox, - reason: 'Runtime.addBinding not yet supported'} do + it 'notifies about DOM mutations' do mutations = [] driver.on_log_event(:mutation) { |mutation| mutations.push(mutation) } driver.navigate.to url_for('dynamic.html') @@ -163,8 +155,7 @@ module WebDriver expect(mutation.old_value).to eq('display:none;') end - describe '#intercept', except: {browser: :firefox, - reason: 'Fetch.enable is not yet supported'} do + describe '#intercept' do it 'continues requests' do requests = [] driver.intercept do |request, &continue| From d7353ed46200a7dcad7906e664583036c7c243f7 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Fri, 31 Jan 2025 14:29:47 +0530 Subject: [PATCH 05/14] Fix formatting --- .../org/openqa/selenium/firefox/FirefoxDriver.java | 14 ++------------ .../node/selenium-webdriver/lib/webdriver.js | 9 ++------- .../node/selenium-webdriver/test/devtools_test.js | 9 ++++----- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/java/src/org/openqa/selenium/firefox/FirefoxDriver.java b/java/src/org/openqa/selenium/firefox/FirefoxDriver.java index 392e106037358..1ecc0c11b1190 100644 --- a/java/src/org/openqa/selenium/firefox/FirefoxDriver.java +++ b/java/src/org/openqa/selenium/firefox/FirefoxDriver.java @@ -24,7 +24,6 @@ import java.nio.file.Path; import java.util.Map; import java.util.Optional; -import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -33,20 +32,11 @@ import org.openqa.selenium.ImmutableCapabilities; import org.openqa.selenium.MutableCapabilities; import org.openqa.selenium.OutputType; -import org.openqa.selenium.PersistentCapabilities; import org.openqa.selenium.Proxy; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.bidi.BiDi; import org.openqa.selenium.bidi.BiDiException; import org.openqa.selenium.bidi.HasBiDi; -import org.openqa.selenium.devtools.CdpEndpointFinder; -import org.openqa.selenium.devtools.CdpInfo; -import org.openqa.selenium.devtools.CdpVersionFinder; -import org.openqa.selenium.devtools.Connection; -import org.openqa.selenium.devtools.DevTools; -import org.openqa.selenium.devtools.DevToolsException; -import org.openqa.selenium.devtools.HasDevTools; -import org.openqa.selenium.devtools.noop.NoOpCdpInfo; import org.openqa.selenium.html5.LocalStorage; import org.openqa.selenium.html5.SessionStorage; import org.openqa.selenium.html5.WebStorage; @@ -157,7 +147,7 @@ private FirefoxDriver( context = new AddHasContext().getImplementation(getCapabilities(), getExecuteMethod()); Capabilities capabilities = super.getCapabilities(); - + Optional webSocketUrl = Optional.ofNullable((String) capabilities.getCapability("webSocketUrl")); @@ -267,7 +257,7 @@ public void setContext(FirefoxCommandContext commandContext) { Require.nonNull("Firefox Command Context", commandContext); context.setContext(commandContext); } - + private Optional createBiDi(Optional biDiUri) { if (biDiUri.isEmpty()) { return Optional.empty(); diff --git a/javascript/node/selenium-webdriver/lib/webdriver.js b/javascript/node/selenium-webdriver/lib/webdriver.js index c2b1b2db1d4b3..0a8548c912a68 100644 --- a/javascript/node/selenium-webdriver/lib/webdriver.js +++ b/javascript/node/selenium-webdriver/lib/webdriver.js @@ -1244,9 +1244,7 @@ class WebDriver { const caps = await this.getCapabilities() if (caps['map_'].get('browserName') === 'firefox') { - throw new Error( - 'CDP support for Firefox is removed. Please switch to WebDriver BiDi.', - ) + throw new Error('CDP support for Firefox is removed. Please switch to WebDriver BiDi.') } if (process.env.SELENIUM_REMOTE_URL) { @@ -1255,10 +1253,7 @@ class WebDriver { debuggerUrl = `ws://${host}/session/${sessionId}/se/cdp` } else { const seCdp = caps['map_'].get('se:cdp') - const vendorInfo = - caps['map_'].get('goog:chromeOptions') || - caps['map_'].get('ms:edgeOptions') || - new Map() + const vendorInfo = caps['map_'].get('goog:chromeOptions') || caps['map_'].get('ms:edgeOptions') || new Map() debuggerUrl = seCdp || vendorInfo['debuggerAddress'] || vendorInfo } this._wsUrl = await this.getWsUrl(debuggerUrl, target, caps) diff --git a/javascript/node/selenium-webdriver/test/devtools_test.js b/javascript/node/selenium-webdriver/test/devtools_test.js index 4f3697202495a..a881177b83006 100644 --- a/javascript/node/selenium-webdriver/test/devtools_test.js +++ b/javascript/node/selenium-webdriver/test/devtools_test.js @@ -117,9 +117,8 @@ suite( }) describe('Network Interception', function () { - ignore(browsers(Browser.SAFARI).it( - 'Allows network requests to be captured and mocked', - async function () { + ignore( + browsers(Browser.SAFARI).it('Allows network requests to be captured and mocked', async function () { const connection = await driver.createCDPConnection('page') let url = fileServer.whereIs('/cheese') let httpResponse = new HttpResponse(url) @@ -130,8 +129,8 @@ suite( assert.strictEqual(body.includes('sausages'), true, `Body contains: ${body}`) }) await driver.get(url) - }, - )) + }), + ) }) }, { browsers: ['chrome'] }, From 95c31fbe1718c0c29a6c7e266954db1c731cff78 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Fri, 31 Jan 2025 16:16:41 +0530 Subject: [PATCH 06/14] [dotnet] Remove CDP support for Firefox --- dotnet/src/webdriver/Firefox/FirefoxDriver.cs | 87 +------------------ 1 file changed, 1 insertion(+), 86 deletions(-) diff --git a/dotnet/src/webdriver/Firefox/FirefoxDriver.cs b/dotnet/src/webdriver/Firefox/FirefoxDriver.cs index 123f0eb6dc545..256d6f2dac55b 100644 --- a/dotnet/src/webdriver/Firefox/FirefoxDriver.cs +++ b/dotnet/src/webdriver/Firefox/FirefoxDriver.cs @@ -17,7 +17,6 @@ // under the License. // -using OpenQA.Selenium.DevTools; using OpenQA.Selenium.Remote; using System; using System.Collections.Generic; @@ -71,11 +70,8 @@ namespace OpenQA.Selenium.Firefox /// } /// /// - public class FirefoxDriver : WebDriver, IDevTools + public class FirefoxDriver : WebDriver { - private const int FirefoxDevToolsProtocolVersion = 85; - private const string FirefoxDevToolsCapabilityName = "moz:debuggerAddress"; - /// /// Command for setting the command context of a Firefox driver. /// @@ -110,8 +106,6 @@ public class FirefoxDriver : WebDriver, IDevTools { GetFullPageScreenshotCommand, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/moz/screenshot/full") } }; - private DevToolsSession devToolsSession; - /// /// Initializes a new instance of the class. /// @@ -244,14 +238,6 @@ public override IFileDetector FileDetector set { } } - /// - /// Gets a value indicating whether a DevTools session is active. - /// - public bool HasActiveDevToolsSession - { - get { return this.devToolsSession != null; } - } - /// /// Sets the command context used when issuing commands to geckodriver. /// @@ -389,68 +375,6 @@ public Screenshot GetFullPageScreenshot() return new Screenshot(base64); } - /// - /// Creates a session to communicate with a browser using the Chromium Developer Tools debugging protocol. - /// - /// The active session to use to communicate with the Chromium Developer Tools debugging protocol. - [Obsolete("CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.")] - public DevToolsSession GetDevToolsSession() - { - return GetDevToolsSession(new DevToolsOptions() { ProtocolVersion = FirefoxDevToolsProtocolVersion }); - } - - /// - /// Creates a session to communicate with a browser using the Chromium Developer Tools debugging protocol. - /// - /// The version of the Chromium Developer Tools protocol to use. Defaults to autodetect the protocol version. - /// The active session to use to communicate with the Chromium Developer Tools debugging protocol. - [Obsolete("Use GetDevToolsSession(DevToolsOptions options)")] - public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion) - { - return GetDevToolsSession(new DevToolsOptions() { ProtocolVersion = devToolsProtocolVersion }); - } - - /// - /// Creates a session to communicate with a browser using a Developer Tools debugging protocol. - /// - /// The active session to use to communicate with the Developer Tools debugging protocol. - [Obsolete("CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.")] - public DevToolsSession GetDevToolsSession(DevToolsOptions options) - { - if (this.devToolsSession == null) - { - if (!this.Capabilities.HasCapability(FirefoxDevToolsCapabilityName)) - { - throw new WebDriverException("Cannot find " + FirefoxDevToolsCapabilityName + " capability for driver"); - } - - string debuggerAddress = this.Capabilities.GetCapability(FirefoxDevToolsCapabilityName).ToString(); - try - { - DevToolsSession session = new DevToolsSession(debuggerAddress, options); - Task.Run(async () => await session.StartSession()).GetAwaiter().GetResult(); - this.devToolsSession = session; - } - catch (Exception e) - { - throw new WebDriverException("Unexpected error creating WebSocket DevTools session.", e); - } - } - - return this.devToolsSession; - } - - /// - /// Closes a DevTools session. - /// - public void CloseDevToolsSession() - { - if (this.devToolsSession != null) - { - Task.Run(async () => await this.devToolsSession.StopSession(true)).GetAwaiter().GetResult(); - } - } - /// /// In derived classes, the method prepares the environment for test execution. /// @@ -467,15 +391,6 @@ protected virtual void PrepareEnvironment() /// disposing the object; otherwise . protected override void Dispose(bool disposing) { - if (disposing) - { - if (this.devToolsSession != null) - { - this.devToolsSession.Dispose(); - this.devToolsSession = null; - } - } - base.Dispose(disposing); } From b71db459f215ef29dfdfc2e5d0354115af2a21e0 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Fri, 31 Jan 2025 16:17:41 +0530 Subject: [PATCH 07/14] [py] Remove CDP support for Firefox --- py/selenium/webdriver/remote/webdriver.py | 17 ++++------------- .../selenium/webdriver/common/devtools_tests.py | 9 ++------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/py/selenium/webdriver/remote/webdriver.py b/py/selenium/webdriver/remote/webdriver.py index 001708db115ef..67fdb96e16085 100644 --- a/py/selenium/webdriver/remote/webdriver.py +++ b/py/selenium/webdriver/remote/webdriver.py @@ -1201,10 +1201,8 @@ def start_devtools(self): devtools = cdp.import_devtools(version) if self.caps["browserName"].lower() == "firefox": - warnings.warn( - "CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.", - DeprecationWarning, - stacklevel=2, + raise RuntimeError( + "CDP support for Firefox has been removed. Please switch to WebDriver BiDi." ) self._websocket_connection = WebSocketConnection(ws_url) targets = self._websocket_connection.execute(devtools.target.get_targets()) @@ -1262,9 +1260,7 @@ def _get_cdp_details(self): debugger_address = self.caps.get("goog:chromeOptions").get("debuggerAddress") elif self.caps.get("browserName") == "MicrosoftEdge": debugger_address = self.caps.get("ms:edgeOptions").get("debuggerAddress") - else: - _firefox = True - debugger_address = self.caps.get("moz:debuggerAddress") + res = http.request("GET", f"http://{debugger_address}/json/version") data = json.loads(res.data) @@ -1273,12 +1269,7 @@ def _get_cdp_details(self): import re - if _firefox: - # Mozilla Automation Team asked to only support 85 - # until WebDriver Bidi is available. - version = 85 - else: - version = re.search(r".*/(\d+)\.", browser_version).group(1) + version = re.search(r".*/(\d+)\.", browser_version).group(1) return version, websocket_url diff --git a/py/test/selenium/webdriver/common/devtools_tests.py b/py/test/selenium/webdriver/common/devtools_tests.py index de194cddbcddf..df89b44a4a8a4 100644 --- a/py/test/selenium/webdriver/common/devtools_tests.py +++ b/py/test/selenium/webdriver/common/devtools_tests.py @@ -20,18 +20,13 @@ @pytest.mark.xfail_safari +@pytest.mark.xfail_firefox def test_check_console_messages(driver, pages): with pytest.warns(None) as record: devtools, connection = driver.start_devtools() console_api_calls = [] - if driver.caps["browserName"].lower() == "firefox": - assert ( - record[0].message.args[0] - == "CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi." - ) - else: - assert len(record) == 0 + assert len(record) == 0 connection.execute(devtools.runtime.enable()) connection.on(devtools.runtime.ConsoleAPICalled, console_api_calls.append) From 64de34a083114b78541fdeb84d3327b72acbaf08 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Fri, 31 Jan 2025 18:02:35 +0530 Subject: [PATCH 08/14] Fix failing tests --- java/test/org/openqa/selenium/devtools/BUILD.bazel | 1 - .../openqa/selenium/devtools/CdpFacadeTest.java | 2 -- .../node/selenium-webdriver/test/devtools_test.js | 4 ++-- .../selenium/webdriver/devtools_spec.rb | 14 ++------------ 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/java/test/org/openqa/selenium/devtools/BUILD.bazel b/java/test/org/openqa/selenium/devtools/BUILD.bazel index c83bfb39a33b9..3636680eb1d59 100644 --- a/java/test/org/openqa/selenium/devtools/BUILD.bazel +++ b/java/test/org/openqa/selenium/devtools/BUILD.bazel @@ -7,7 +7,6 @@ java_selenium_test_suite( srcs = glob(["*Test.java"]), browsers = [ "chrome", - "firefox", "edge", ], tags = [ diff --git a/java/test/org/openqa/selenium/devtools/CdpFacadeTest.java b/java/test/org/openqa/selenium/devtools/CdpFacadeTest.java index 6022f9cbdf54e..c9cb972329489 100644 --- a/java/test/org/openqa/selenium/devtools/CdpFacadeTest.java +++ b/java/test/org/openqa/selenium/devtools/CdpFacadeTest.java @@ -61,7 +61,6 @@ public static void stopServer() { } @Test - @NotYetImplemented(value = Browser.FIREFOX, reason = "Network interception not yet supported") public void networkInterceptorAndAuthHandlersDoNotFight() { assumeThat(driver).isInstanceOf(HasAuthentication.class); @@ -95,7 +94,6 @@ public void networkInterceptorAndAuthHandlersDoNotFight() { } @Test - @NotYetImplemented(value = Browser.FIREFOX, reason = "Network interception not yet supported") public void canAuthenticate() { assumeThat(driver).isInstanceOf(HasAuthentication.class); diff --git a/javascript/node/selenium-webdriver/test/devtools_test.js b/javascript/node/selenium-webdriver/test/devtools_test.js index a881177b83006..df8b6826f5992 100644 --- a/javascript/node/selenium-webdriver/test/devtools_test.js +++ b/javascript/node/selenium-webdriver/test/devtools_test.js @@ -118,7 +118,7 @@ suite( describe('Network Interception', function () { ignore( - browsers(Browser.SAFARI).it('Allows network requests to be captured and mocked', async function () { + browsers(Browser.SAFARI)).it('Allows network requests to be captured and mocked', async function () { const connection = await driver.createCDPConnection('page') let url = fileServer.whereIs('/cheese') let httpResponse = new HttpResponse(url) @@ -129,7 +129,7 @@ suite( assert.strictEqual(body.includes('sausages'), true, `Body contains: ${body}`) }) await driver.get(url) - }), + }, ) }) }, diff --git a/rb/spec/integration/selenium/webdriver/devtools_spec.rb b/rb/spec/integration/selenium/webdriver/devtools_spec.rb index b8bdd29f44684..ec11217b720bc 100644 --- a/rb/spec/integration/selenium/webdriver/devtools_spec.rb +++ b/rb/spec/integration/selenium/webdriver/devtools_spec.rb @@ -112,19 +112,9 @@ module WebDriver expect(logs).to include( an_object_having_attributes(type: :log, args: [hash_including('type' => 'object')]) ) - end - - it 'notifies about document log messages' do - logs = [] - driver.on_log_event(:console) { |log| logs.push(log) } - driver.navigate.to url_for('javascriptPage.html') - - driver.execute_script('console.log(document);') - wait.until { !logs.empty? } - expect(logs).to include( - an_object_having_attributes(type: :log, args: [hash_including('location')]) - ) + an_object_having_attributes(type: :log, args: [hash_including('location')]) + ) end it 'notifies about exceptions' do From e3781be327eb1e352e37423cb3d2a2eb29bd39ee Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Mon, 3 Feb 2025 10:51:48 +0530 Subject: [PATCH 09/14] [js] Fix linting --- .../selenium-webdriver/test/devtools_test.js | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/javascript/node/selenium-webdriver/test/devtools_test.js b/javascript/node/selenium-webdriver/test/devtools_test.js index df8b6826f5992..a0be45e318c45 100644 --- a/javascript/node/selenium-webdriver/test/devtools_test.js +++ b/javascript/node/selenium-webdriver/test/devtools_test.js @@ -117,20 +117,18 @@ suite( }) describe('Network Interception', function () { - ignore( - browsers(Browser.SAFARI)).it('Allows network requests to be captured and mocked', async function () { - const connection = await driver.createCDPConnection('page') - let url = fileServer.whereIs('/cheese') - let httpResponse = new HttpResponse(url) - httpResponse.addHeaders('Content-Type', 'UTF-8') - httpResponse.body = 'sausages' - await driver.onIntercept(connection, httpResponse, async function () { - let body = await driver.getPageSource() - assert.strictEqual(body.includes('sausages'), true, `Body contains: ${body}`) - }) - await driver.get(url) - }, - ) + ignore(browsers(Browser.SAFARI)).it('Allows network requests to be captured and mocked', async function () { + const connection = await driver.createCDPConnection('page') + let url = fileServer.whereIs('/cheese') + let httpResponse = new HttpResponse(url) + httpResponse.addHeaders('Content-Type', 'UTF-8') + httpResponse.body = 'sausages' + await driver.onIntercept(connection, httpResponse, async function () { + let body = await driver.getPageSource() + assert.strictEqual(body.includes('sausages'), true, `Body contains: ${body}`) + }) + await driver.get(url) + }) }) }, { browsers: ['chrome'] }, From 9a17748dd6c6e99587bf3c14fa6230a92596fc9d Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Mon, 3 Feb 2025 11:44:28 +0530 Subject: [PATCH 10/14] Fix formatting --- py/selenium/webdriver/remote/webdriver.py | 1 - rb/spec/integration/selenium/webdriver/devtools_spec.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/py/selenium/webdriver/remote/webdriver.py b/py/selenium/webdriver/remote/webdriver.py index 67fdb96e16085..566e0bc577e36 100644 --- a/py/selenium/webdriver/remote/webdriver.py +++ b/py/selenium/webdriver/remote/webdriver.py @@ -1255,7 +1255,6 @@ def _get_cdp_details(self): import urllib3 http = urllib3.PoolManager() - _firefox = False if self.caps.get("browserName") == "chrome": debugger_address = self.caps.get("goog:chromeOptions").get("debuggerAddress") elif self.caps.get("browserName") == "MicrosoftEdge": diff --git a/rb/spec/integration/selenium/webdriver/devtools_spec.rb b/rb/spec/integration/selenium/webdriver/devtools_spec.rb index ec11217b720bc..2247424a6a503 100644 --- a/rb/spec/integration/selenium/webdriver/devtools_spec.rb +++ b/rb/spec/integration/selenium/webdriver/devtools_spec.rb @@ -113,8 +113,8 @@ module WebDriver an_object_having_attributes(type: :log, args: [hash_including('type' => 'object')]) ) expect(logs).to include( - an_object_having_attributes(type: :log, args: [hash_including('location')]) - ) + an_object_having_attributes(type: :log, args: [hash_including('location')]) + ) end it 'notifies about exceptions' do From c01f39936e54accec2f4f831afca93e6d707007b Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Mon, 3 Feb 2025 12:22:38 +0530 Subject: [PATCH 11/14] Fix formatting --- java/test/org/openqa/selenium/devtools/CdpFacadeTest.java | 2 -- py/selenium/webdriver/remote/webdriver.py | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/java/test/org/openqa/selenium/devtools/CdpFacadeTest.java b/java/test/org/openqa/selenium/devtools/CdpFacadeTest.java index c9cb972329489..a2d2d3040f23a 100644 --- a/java/test/org/openqa/selenium/devtools/CdpFacadeTest.java +++ b/java/test/org/openqa/selenium/devtools/CdpFacadeTest.java @@ -35,8 +35,6 @@ import org.openqa.selenium.remote.http.Contents; import org.openqa.selenium.remote.http.HttpResponse; import org.openqa.selenium.remote.http.Route; -import org.openqa.selenium.testing.NotYetImplemented; -import org.openqa.selenium.testing.drivers.Browser; class CdpFacadeTest extends DevToolsTestBase { diff --git a/py/selenium/webdriver/remote/webdriver.py b/py/selenium/webdriver/remote/webdriver.py index 566e0bc577e36..8c98905477fe2 100644 --- a/py/selenium/webdriver/remote/webdriver.py +++ b/py/selenium/webdriver/remote/webdriver.py @@ -1201,9 +1201,7 @@ def start_devtools(self): devtools = cdp.import_devtools(version) if self.caps["browserName"].lower() == "firefox": - raise RuntimeError( - "CDP support for Firefox has been removed. Please switch to WebDriver BiDi." - ) + raise RuntimeError("CDP support for Firefox has been removed. Please switch to WebDriver BiDi.") self._websocket_connection = WebSocketConnection(ws_url) targets = self._websocket_connection.execute(devtools.target.get_targets()) target_id = targets[0].target_id From 030d26221ecdabf13e8b12eece640e05b124ec14 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Mon, 3 Feb 2025 12:23:42 +0530 Subject: [PATCH 12/14] Fix formatting --- rb/spec/integration/selenium/webdriver/devtools_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rb/spec/integration/selenium/webdriver/devtools_spec.rb b/rb/spec/integration/selenium/webdriver/devtools_spec.rb index 2247424a6a503..ccfc044b22569 100644 --- a/rb/spec/integration/selenium/webdriver/devtools_spec.rb +++ b/rb/spec/integration/selenium/webdriver/devtools_spec.rb @@ -108,7 +108,7 @@ module WebDriver driver.execute_script('console.log(document);') wait.until { !logs.empty? } - + expect(logs).to include( an_object_having_attributes(type: :log, args: [hash_including('type' => 'object')]) ) From cfe84673284e925c2ba2199bbfb7e4b05f538fbb Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Mon, 3 Feb 2025 12:39:23 +0530 Subject: [PATCH 13/14] Fix formatting --- rb/spec/integration/selenium/webdriver/devtools_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rb/spec/integration/selenium/webdriver/devtools_spec.rb b/rb/spec/integration/selenium/webdriver/devtools_spec.rb index ccfc044b22569..2247424a6a503 100644 --- a/rb/spec/integration/selenium/webdriver/devtools_spec.rb +++ b/rb/spec/integration/selenium/webdriver/devtools_spec.rb @@ -108,7 +108,7 @@ module WebDriver driver.execute_script('console.log(document);') wait.until { !logs.empty? } - + expect(logs).to include( an_object_having_attributes(type: :log, args: [hash_including('type' => 'object')]) ) From bd83aa5f02cfc6bccd7bcbd8f6e81c918ce84b59 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Mon, 3 Feb 2025 13:35:39 +0530 Subject: [PATCH 14/14] [java] Remove debugger address cap from tests --- java/src/org/openqa/selenium/firefox/FirefoxOptions.java | 1 - 1 file changed, 1 deletion(-) diff --git a/java/src/org/openqa/selenium/firefox/FirefoxOptions.java b/java/src/org/openqa/selenium/firefox/FirefoxOptions.java index 6f514c79aec60..c5c22f7791a73 100644 --- a/java/src/org/openqa/selenium/firefox/FirefoxOptions.java +++ b/java/src/org/openqa/selenium/firefox/FirefoxOptions.java @@ -62,7 +62,6 @@ public class FirefoxOptions extends AbstractDriverOptions { 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/.