Skip to content

Commit

Permalink
[java] close the CDP connection on quit for FF (#11109)
Browse files Browse the repository at this point in the history
close the CDP connection on quit for FF

The FirefoxDriver did not close the CDP connection on quit like the
ChromiumDriver does.

[skip ci]
  • Loading branch information
joerg1985 authored Oct 12, 2022
1 parent 9e91560 commit 0cceb8a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion java/src/org/openqa/selenium/firefox/FirefoxDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class FirefoxDriver extends RemoteWebDriver
private final Optional<URI> cdpUri;
private final Optional<URI> biDiUri;
protected FirefoxBinary binary;
private Connection connection;
private DevTools devTools;
private BiDi biDi;
public FirefoxDriver() {
Expand Down Expand Up @@ -246,7 +247,7 @@ public Optional<DevTools> maybeGetDevTools() {
ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri);
HttpClient wsClient = clientFactory.createClient(wsConfig);

Connection connection = new Connection(wsClient, wsUri.toString());
connection = new Connection(wsClient, wsUri.toString());
CdpInfo cdpInfo = new CdpVersionFinder().match("85.0").orElseGet(NoOpCdpInfo::new);
devTools = new DevTools(cdpInfo::getDomains, connection);

Expand Down Expand Up @@ -298,6 +299,14 @@ public BiDi getBiDi() {
.orElseThrow(() -> new DevToolsException("Unable to initialize Bidi connection"));
}

@Override
public void quit() {
if (connection != null) {
connection.close();
}
super.quit();
}

public static final class SystemProperty {

/**
Expand Down

0 comments on commit 0cceb8a

Please sign in to comment.