Skip to content

Commit 7a469e0

Browse files
committed
[java][bidi] Close BiDi connection on webdriver quit command
1 parent b529aba commit 7a469e0

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed
+24-3
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,45 @@
11
load("@rules_jvm_external//:defs.bzl", "artifact")
22
load("//java:defs.bzl", "java_library")
33

4+
AUGMENTER_SRCS = [
5+
"BiDiProvider.java",
6+
]
7+
8+
java_library(
9+
name = "augmenter",
10+
srcs = AUGMENTER_SRCS,
11+
visibility = [
12+
"//java/src/org/openqa/selenium/remote:__pkg__",
13+
],
14+
deps = [
15+
":bidi",
16+
"//java:auto-service",
17+
"//java/src/org/openqa/selenium:core",
18+
"//java/src/org/openqa/selenium/remote:api",
19+
"//java/src/org/openqa/selenium/remote/http",
20+
],
21+
)
22+
423
java_library(
524
name = "bidi",
625
srcs = glob([
726
"*.java",
827
"log/*.java",
928
"browsingcontext/*.java"
10-
]),
29+
],
30+
exclude = AUGMENTER_SRCS,
31+
),
1132
visibility = [
1233
"//java/src/org/openqa/selenium/bidi:__subpackages__",
1334
"//java/src/org/openqa/selenium/firefox:__subpackages__",
35+
"//java/src/org/openqa/selenium/remote:__pkg__",
1436
"//java/test/org/openqa/selenium/bidi:__subpackages__",
1537
"//java/test/org/openqa/selenium/grid:__subpackages__",
1638
],
1739
deps = [
18-
"//java:auto-service",
1940
"//java/src/org/openqa/selenium:core",
2041
"//java/src/org/openqa/selenium/json",
21-
"//java/src/org/openqa/selenium/remote",
42+
"//java/src/org/openqa/selenium/remote/http",
2243
artifact("com.google.guava:guava"),
2344
],
2445
)

java/src/org/openqa/selenium/bidi/BiDiProvider.java

-8
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
import com.google.auto.service.AutoService;
2121

2222
import org.openqa.selenium.Capabilities;
23-
import org.openqa.selenium.devtools.CdpEndpointFinder;
24-
import org.openqa.selenium.devtools.CdpInfo;
25-
import org.openqa.selenium.devtools.CdpVersionFinder;
26-
import org.openqa.selenium.devtools.DevTools;
27-
import org.openqa.selenium.devtools.HasDevTools;
28-
import org.openqa.selenium.devtools.SeleniumCdpConnection;
29-
import org.openqa.selenium.devtools.noop.NoOpCdpInfo;
3023
import org.openqa.selenium.remote.AugmenterProvider;
3124
import org.openqa.selenium.remote.ExecuteMethod;
3225
import org.openqa.selenium.remote.http.ClientConfig;
@@ -36,7 +29,6 @@
3629
import java.net.URISyntaxException;
3730
import java.util.Optional;
3831
import java.util.function.Predicate;
39-
import java.util.logging.Logger;
4032

4133
@AutoService(AugmenterProvider.class)
4234
public class BiDiProvider implements AugmenterProvider<HasBiDi> {

java/src/org/openqa/selenium/remote/BUILD.bazel

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ java_export(
2424
exports = [
2525
":api",
2626
"//java/src/org/openqa/selenium:core",
27+
"//java/src/org/openqa/selenium/bidi",
28+
"//java/src/org/openqa/selenium/bidi:augmenter",
2729
"//java/src/org/openqa/selenium/devtools",
2830
"//java/src/org/openqa/selenium/devtools:augmenter",
2931
"//java/src/org/openqa/selenium/io",
@@ -44,11 +46,13 @@ java_library(
4446
],
4547
visibility = [
4648
"//java/src/org/openqa/selenium/devtools:__pkg__",
49+
"//java/src/org/openqa/selenium/bidi:__pkg__",
4750
],
4851
exports = [
4952
],
5053
deps = [
5154
"//java/src/org/openqa/selenium:core",
55+
"//java/src/org/openqa/selenium/bidi",
5256
"//java/src/org/openqa/selenium/concurrent",
5357
"//java/src/org/openqa/selenium/devtools",
5458
"//java/src/org/openqa/selenium/io",

java/src/org/openqa/selenium/remote/RemoteWebDriver.java

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import org.openqa.selenium.WebDriverException;
4646
import org.openqa.selenium.WebElement;
4747
import org.openqa.selenium.WindowType;
48+
import org.openqa.selenium.bidi.BiDi;
49+
import org.openqa.selenium.bidi.HasBiDi;
4850
import org.openqa.selenium.devtools.DevTools;
4951
import org.openqa.selenium.devtools.HasDevTools;
5052
import org.openqa.selenium.interactions.Interactive;
@@ -444,6 +446,10 @@ public void quit() {
444446
((HasDevTools) this).maybeGetDevTools().ifPresent(DevTools::close);
445447
}
446448

449+
if (this instanceof HasBiDi) {
450+
((HasBiDi) this).maybeGetBiDi().ifPresent(BiDi::close);
451+
}
452+
447453
execute(DriverCommand.QUIT);
448454
} finally {
449455
sessionId = null;

0 commit comments

Comments
 (0)