Skip to content

Commit 98c6eb0

Browse files
authored
[java] Add convenience for enabling BiDi (#14029)
Related to #13991
1 parent 062c125 commit 98c6eb0

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

java/src/org/openqa/selenium/chromium/ChromiumOptions.java

+5
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ public T addEncodedExtensions(List<String> encoded) {
186186
return (T) this;
187187
}
188188

189+
public T enableBiDi() {
190+
setCapability("webSocketUrl", true);
191+
return (T) this;
192+
}
193+
189194
/**
190195
* Sets an experimental option. Useful for new ChromeDriver options not yet exposed through the
191196
* {@link ChromiumOptions} API.

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

+5
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ private FirefoxOptions setFirefoxOption(String key, Object value) {
294294
return this;
295295
}
296296

297+
public FirefoxOptions enableBiDi() {
298+
setCapability("webSocketUrl", true);
299+
return this;
300+
}
301+
297302
@Override
298303
protected Set<String> getExtraCapabilityNames() {
299304
Set<String> names = new TreeSet<>();

java/test/org/openqa/selenium/bidi/BiDiSessionCleanUpTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BiDiSessionCleanUpTest {
3636
void shouldNotCloseBiDiSessionIfOneWindowIsClosed() {
3737
FirefoxOptions options = (FirefoxOptions) Browser.FIREFOX.getCapabilities();
3838
// Enable BiDi
39-
options.setCapability("webSocketUrl", true);
39+
options.enableBiDi();
4040

4141
driver = new FirefoxDriver(options);
4242

@@ -64,7 +64,7 @@ void shouldNotCloseBiDiSessionIfOneWindowIsClosed() {
6464
void shouldCloseBiDiSessionIfLastWindowIsClosed() {
6565
FirefoxOptions options = (FirefoxOptions) Browser.FIREFOX.getCapabilities();
6666
// Enable BiDi
67-
options.setCapability("webSocketUrl", true);
67+
options.enableBiDi();
6868

6969
driver = new FirefoxDriver(options);
7070

java/test/org/openqa/selenium/testing/drivers/Browser.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public Capabilities getCapabilities() {
5959
prefs.put("exited_cleanly", true);
6060
options.setExperimentalOption("prefs", prefs);
6161

62-
options.setCapability("webSocketUrl", true);
62+
options.enableBiDi();
6363

6464
return options;
6565
}
@@ -90,7 +90,7 @@ public Capabilities getCapabilities() {
9090
prefs.put("exited_cleanly", true);
9191
options.setExperimentalOption("prefs", prefs);
9292

93-
options.setCapability("webSocketUrl", true);
93+
options.enableBiDi();
9494

9595
return options;
9696
}
@@ -129,7 +129,7 @@ public Capabilities getCapabilities() {
129129
options.addArguments("-headless");
130130
}
131131

132-
options.setCapability("webSocketUrl", true);
132+
options.enableBiDi();
133133

134134
return options;
135135
}

0 commit comments

Comments
 (0)