[java] close the CDP connection on quit for FF
close the CDP connection on quit for FF
The FirefoxDriver did not close the CDP connection on quit like the
ChromiumDriver does.
[skip ci]
private final Optional<URI> cdpUri;
private final Optional<URI> biDiUri;
protected FirefoxBinary binary;
+ private Connection connection;
private DevTools devTools;
private BiDi biDi;
public FirefoxDriver() {
@@ -246,7 +247,7 @@ public void setContext(FirefoxCommandContext commandContext) {
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);
@@ -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 {
/**
