Skip to content

Commit 29e858f

Browse files
authored
[java][js][rb][py][dotnet] Remove firefox cdp (#15200)
Related to #11736
1 parent 98b22f8 commit 29e858f

File tree

12 files changed

+34
-296
lines changed

12 files changed

+34
-296
lines changed

dotnet/src/webdriver/Firefox/FirefoxDriver.cs

+1-86
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
// under the License.
1818
// </copyright>
1919

20-
using OpenQA.Selenium.DevTools;
2120
using OpenQA.Selenium.Remote;
2221
using System;
2322
using System.Collections.Generic;
@@ -71,11 +70,8 @@ namespace OpenQA.Selenium.Firefox
7170
/// }
7271
/// </code>
7372
/// </example>
74-
public class FirefoxDriver : WebDriver, IDevTools
73+
public class FirefoxDriver : WebDriver
7574
{
76-
private const int FirefoxDevToolsProtocolVersion = 85;
77-
private const string FirefoxDevToolsCapabilityName = "moz:debuggerAddress";
78-
7975
/// <summary>
8076
/// Command for setting the command context of a Firefox driver.
8177
/// </summary>
@@ -110,8 +106,6 @@ public class FirefoxDriver : WebDriver, IDevTools
110106
{ GetFullPageScreenshotCommand, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/moz/screenshot/full") }
111107
};
112108

113-
private DevToolsSession devToolsSession;
114-
115109
/// <summary>
116110
/// Initializes a new instance of the <see cref="FirefoxDriver"/> class.
117111
/// </summary>
@@ -244,14 +238,6 @@ public override IFileDetector FileDetector
244238
set { }
245239
}
246240

247-
/// <summary>
248-
/// Gets a value indicating whether a DevTools session is active.
249-
/// </summary>
250-
public bool HasActiveDevToolsSession
251-
{
252-
get { return this.devToolsSession != null; }
253-
}
254-
255241
/// <summary>
256242
/// Sets the command context used when issuing commands to geckodriver.
257243
/// </summary>
@@ -389,68 +375,6 @@ public Screenshot GetFullPageScreenshot()
389375
return new Screenshot(base64);
390376
}
391377

392-
/// <summary>
393-
/// Creates a session to communicate with a browser using the Chromium Developer Tools debugging protocol.
394-
/// </summary>
395-
/// <returns>The active session to use to communicate with the Chromium Developer Tools debugging protocol.</returns>
396-
[Obsolete("CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.")]
397-
public DevToolsSession GetDevToolsSession()
398-
{
399-
return GetDevToolsSession(new DevToolsOptions() { ProtocolVersion = FirefoxDevToolsProtocolVersion });
400-
}
401-
402-
/// <summary>
403-
/// Creates a session to communicate with a browser using the Chromium Developer Tools debugging protocol.
404-
/// </summary>
405-
/// <param name="devToolsProtocolVersion">The version of the Chromium Developer Tools protocol to use. Defaults to autodetect the protocol version.</param>
406-
/// <returns>The active session to use to communicate with the Chromium Developer Tools debugging protocol.</returns>
407-
[Obsolete("Use GetDevToolsSession(DevToolsOptions options)")]
408-
public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion)
409-
{
410-
return GetDevToolsSession(new DevToolsOptions() { ProtocolVersion = devToolsProtocolVersion });
411-
}
412-
413-
/// <summary>
414-
/// Creates a session to communicate with a browser using a Developer Tools debugging protocol.
415-
/// </summary>
416-
/// <returns>The active session to use to communicate with the Developer Tools debugging protocol.</returns>
417-
[Obsolete("CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.")]
418-
public DevToolsSession GetDevToolsSession(DevToolsOptions options)
419-
{
420-
if (this.devToolsSession == null)
421-
{
422-
if (!this.Capabilities.HasCapability(FirefoxDevToolsCapabilityName))
423-
{
424-
throw new WebDriverException("Cannot find " + FirefoxDevToolsCapabilityName + " capability for driver");
425-
}
426-
427-
string debuggerAddress = this.Capabilities.GetCapability(FirefoxDevToolsCapabilityName).ToString();
428-
try
429-
{
430-
DevToolsSession session = new DevToolsSession(debuggerAddress, options);
431-
Task.Run(async () => await session.StartSession()).GetAwaiter().GetResult();
432-
this.devToolsSession = session;
433-
}
434-
catch (Exception e)
435-
{
436-
throw new WebDriverException("Unexpected error creating WebSocket DevTools session.", e);
437-
}
438-
}
439-
440-
return this.devToolsSession;
441-
}
442-
443-
/// <summary>
444-
/// Closes a DevTools session.
445-
/// </summary>
446-
public void CloseDevToolsSession()
447-
{
448-
if (this.devToolsSession != null)
449-
{
450-
Task.Run(async () => await this.devToolsSession.StopSession(true)).GetAwaiter().GetResult();
451-
}
452-
}
453-
454378
/// <summary>
455379
/// In derived classes, the <see cref="PrepareEnvironment"/> method prepares the environment for test execution.
456380
/// </summary>
@@ -467,15 +391,6 @@ protected virtual void PrepareEnvironment()
467391
/// disposing the object; otherwise <see langword="false"/>.</param>
468392
protected override void Dispose(bool disposing)
469393
{
470-
if (disposing)
471-
{
472-
if (this.devToolsSession != null)
473-
{
474-
this.devToolsSession.Dispose();
475-
this.devToolsSession = null;
476-
}
477-
}
478-
479394
base.Dispose(disposing);
480395
}
481396

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

+2-104
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.nio.file.Path;
2525
import java.util.Map;
2626
import java.util.Optional;
27-
import java.util.logging.Level;
2827
import java.util.logging.Logger;
2928
import java.util.stream.Collectors;
3029
import java.util.stream.Stream;
@@ -33,20 +32,11 @@
3332
import org.openqa.selenium.ImmutableCapabilities;
3433
import org.openqa.selenium.MutableCapabilities;
3534
import org.openqa.selenium.OutputType;
36-
import org.openqa.selenium.PersistentCapabilities;
3735
import org.openqa.selenium.Proxy;
3836
import org.openqa.selenium.WebDriverException;
3937
import org.openqa.selenium.bidi.BiDi;
4038
import org.openqa.selenium.bidi.BiDiException;
4139
import org.openqa.selenium.bidi.HasBiDi;
42-
import org.openqa.selenium.devtools.CdpEndpointFinder;
43-
import org.openqa.selenium.devtools.CdpInfo;
44-
import org.openqa.selenium.devtools.CdpVersionFinder;
45-
import org.openqa.selenium.devtools.Connection;
46-
import org.openqa.selenium.devtools.DevTools;
47-
import org.openqa.selenium.devtools.DevToolsException;
48-
import org.openqa.selenium.devtools.HasDevTools;
49-
import org.openqa.selenium.devtools.noop.NoOpCdpInfo;
5040
import org.openqa.selenium.html5.LocalStorage;
5141
import org.openqa.selenium.html5.SessionStorage;
5242
import org.openqa.selenium.html5.WebStorage;
@@ -78,18 +68,15 @@
7868
* </pre>
7969
*/
8070
public class FirefoxDriver extends RemoteWebDriver
81-
implements WebStorage, HasExtensions, HasFullPageScreenshot, HasContext, HasDevTools, HasBiDi {
71+
implements WebStorage, HasExtensions, HasFullPageScreenshot, HasContext, HasBiDi {
8272

8373
private static final Logger LOG = Logger.getLogger(FirefoxDriver.class.getName());
8474
private final Capabilities capabilities;
8575
private final RemoteWebStorage webStorage;
8676
private final HasExtensions extensions;
8777
private final HasFullPageScreenshot fullPageScreenshot;
8878
private final HasContext context;
89-
private final Optional<URI> cdpUri;
9079
private final Optional<URI> biDiUri;
91-
private Connection connection;
92-
private DevTools devTools;
9380
private final Optional<BiDi> biDi;
9481

9582
/**
@@ -160,41 +147,6 @@ private FirefoxDriver(
160147
context = new AddHasContext().getImplementation(getCapabilities(), getExecuteMethod());
161148

162149
Capabilities capabilities = super.getCapabilities();
163-
HttpClient.Factory factory = HttpClient.Factory.createDefault();
164-
165-
Optional<URI> reportedUri =
166-
CdpEndpointFinder.getReportedUri("moz:debuggerAddress", capabilities);
167-
168-
if (reportedUri.isPresent() && !capabilities.is("webSocketUrl")) {
169-
LOG.warning(
170-
"CDP support for Firefox is deprecated and will be removed in future versions. "
171-
+ "Please switch to WebDriver BiDi.");
172-
}
173-
174-
Optional<HttpClient> client =
175-
reportedUri.map(uri -> CdpEndpointFinder.getHttpClient(factory, uri));
176-
Optional<URI> cdpUri;
177-
178-
try {
179-
cdpUri = client.flatMap(CdpEndpointFinder::getCdpEndPoint);
180-
} catch (Exception e) {
181-
try {
182-
client.ifPresent(HttpClient::close);
183-
} catch (Exception ex) {
184-
e.addSuppressed(ex);
185-
}
186-
throw e;
187-
}
188-
189-
try {
190-
client.ifPresent(HttpClient::close);
191-
} catch (Exception e) {
192-
LOG.log(
193-
Level.FINE,
194-
"failed to close the http client used to check the reported CDP endpoint: "
195-
+ reportedUri.get(),
196-
e);
197-
}
198150

199151
Optional<String> webSocketUrl =
200152
Optional.ofNullable((String) capabilities.getCapability("webSocketUrl"));
@@ -212,16 +164,7 @@ private FirefoxDriver(
212164

213165
this.biDi = createBiDi(biDiUri);
214166

215-
this.cdpUri = cdpUri;
216-
this.capabilities =
217-
cdpUri
218-
.map(
219-
uri ->
220-
new ImmutableCapabilities(
221-
new PersistentCapabilities(capabilities)
222-
.setCapability("se:cdp", uri.toString())
223-
.setCapability("se:cdpVersion", "85.0")))
224-
.orElse(new ImmutableCapabilities(capabilities));
167+
this.capabilities = new ImmutableCapabilities(capabilities);
225168
}
226169

227170
@Beta
@@ -315,51 +258,6 @@ public void setContext(FirefoxCommandContext commandContext) {
315258
context.setContext(commandContext);
316259
}
317260

318-
/**
319-
* @deprecated Use W3C-compliant BiDi protocol. Use {{@link #maybeGetBiDi()}}
320-
*/
321-
@Deprecated
322-
@Override
323-
public Optional<DevTools> maybeGetDevTools() {
324-
if (devTools != null) {
325-
return Optional.of(devTools);
326-
}
327-
328-
if (!cdpUri.isPresent()) {
329-
return Optional.empty();
330-
}
331-
332-
URI wsUri =
333-
cdpUri.orElseThrow(
334-
() ->
335-
new DevToolsException(
336-
"This version of Firefox or geckodriver does not support CDP"));
337-
HttpClient.Factory clientFactory = HttpClient.Factory.createDefault();
338-
339-
ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri);
340-
HttpClient wsClient = clientFactory.createClient(wsConfig);
341-
342-
connection = new Connection(wsClient, wsUri.toString());
343-
CdpInfo cdpInfo = new CdpVersionFinder().match("85.0").orElseGet(NoOpCdpInfo::new);
344-
devTools = new DevTools(cdpInfo::getDomains, connection);
345-
346-
return Optional.of(devTools);
347-
}
348-
349-
/**
350-
* @deprecated Use W3C-compliant BiDi protocol. Use {{@link #getBiDi()}}
351-
*/
352-
@Deprecated
353-
@Override
354-
public DevTools getDevTools() {
355-
if (!cdpUri.isPresent()) {
356-
throw new DevToolsException("This version of Firefox or geckodriver does not support CDP");
357-
}
358-
359-
return maybeGetDevTools()
360-
.orElseThrow(() -> new DevToolsException("Unable to initialize CDP connection"));
361-
}
362-
363261
private Optional<BiDi> createBiDi(Optional<URI> biDiUri) {
364262
if (biDiUri.isEmpty()) {
365263
return Optional.empty();

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

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public class FirefoxOptions extends AbstractDriverOptions<FirefoxOptions> {
6262
public FirefoxOptions() {
6363
setCapability(CapabilityType.BROWSER_NAME, FIREFOX.browserName());
6464
setAcceptInsecureCerts(true);
65-
setCapability("moz:debuggerAddress", true);
6665
// Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference
6766
// will enable it.
6867
// https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/.

java/test/org/openqa/selenium/devtools/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ java_selenium_test_suite(
77
srcs = glob(["*Test.java"]),
88
browsers = [
99
"chrome",
10-
"firefox",
1110
"edge",
1211
],
1312
tags = [

java/test/org/openqa/selenium/devtools/CdpFacadeTest.java

-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
import org.openqa.selenium.remote.http.Contents;
3636
import org.openqa.selenium.remote.http.HttpResponse;
3737
import org.openqa.selenium.remote.http.Route;
38-
import org.openqa.selenium.testing.NotYetImplemented;
39-
import org.openqa.selenium.testing.drivers.Browser;
4038

4139
class CdpFacadeTest extends DevToolsTestBase {
4240

@@ -61,7 +59,6 @@ public static void stopServer() {
6159
}
6260

6361
@Test
64-
@NotYetImplemented(value = Browser.FIREFOX, reason = "Network interception not yet supported")
6562
public void networkInterceptorAndAuthHandlersDoNotFight() {
6663
assumeThat(driver).isInstanceOf(HasAuthentication.class);
6764

@@ -95,7 +92,6 @@ public void networkInterceptorAndAuthHandlersDoNotFight() {
9592
}
9693

9794
@Test
98-
@NotYetImplemented(value = Browser.FIREFOX, reason = "Network interception not yet supported")
9995
public void canAuthenticate() {
10096
assumeThat(driver).isInstanceOf(HasAuthentication.class);
10197

javascript/node/selenium-webdriver/lib/webdriver.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -1244,9 +1244,7 @@ class WebDriver {
12441244
const caps = await this.getCapabilities()
12451245

12461246
if (caps['map_'].get('browserName') === 'firefox') {
1247-
console.warn(
1248-
'CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.',
1249-
)
1247+
throw new Error('CDP support for Firefox is removed. Please switch to WebDriver BiDi.')
12501248
}
12511249

12521250
if (process.env.SELENIUM_REMOTE_URL) {
@@ -1255,11 +1253,7 @@ class WebDriver {
12551253
debuggerUrl = `ws://${host}/session/${sessionId}/se/cdp`
12561254
} else {
12571255
const seCdp = caps['map_'].get('se:cdp')
1258-
const vendorInfo =
1259-
caps['map_'].get('goog:chromeOptions') ||
1260-
caps['map_'].get('ms:edgeOptions') ||
1261-
caps['map_'].get('moz:debuggerAddress') ||
1262-
new Map()
1256+
const vendorInfo = caps['map_'].get('goog:chromeOptions') || caps['map_'].get('ms:edgeOptions') || new Map()
12631257
debuggerUrl = seCdp || vendorInfo['debuggerAddress'] || vendorInfo
12641258
}
12651259
this._wsUrl = await this.getWsUrl(debuggerUrl, target, caps)

0 commit comments

Comments
 (0)