Skip to content

Commit

Permalink
[java] Add convenience for enabling BiDi
Browse files Browse the repository at this point in the history
Related to #13991
  • Loading branch information
pujagani committed May 24, 2024
1 parent 062c125 commit 0e8afac
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions java/src/org/openqa/selenium/chromium/ChromiumOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ public T addEncodedExtensions(List<String> encoded) {
return (T) this;
}

public T enableBiDi() {
setCapability("webSocketUrl", true);
return (T) this;
}

/**
* Sets an experimental option. Useful for new ChromeDriver options not yet exposed through the
* {@link ChromiumOptions} API.
Expand Down
5 changes: 5 additions & 0 deletions java/src/org/openqa/selenium/firefox/FirefoxOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ private FirefoxOptions setFirefoxOption(String key, Object value) {
return this;
}

public FirefoxOptions enableBiDi() {
setCapability("webSocketUrl", true);
return this;
}

@Override
protected Set<String> getExtraCapabilityNames() {
Set<String> names = new TreeSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BiDiSessionCleanUpTest {
void shouldNotCloseBiDiSessionIfOneWindowIsClosed() {
FirefoxOptions options = (FirefoxOptions) Browser.FIREFOX.getCapabilities();
// Enable BiDi
options.setCapability("webSocketUrl", true);
options.enableBiDi();

driver = new FirefoxDriver(options);

Expand Down Expand Up @@ -64,7 +64,7 @@ void shouldNotCloseBiDiSessionIfOneWindowIsClosed() {
void shouldCloseBiDiSessionIfLastWindowIsClosed() {
FirefoxOptions options = (FirefoxOptions) Browser.FIREFOX.getCapabilities();
// Enable BiDi
options.setCapability("webSocketUrl", true);
options.enableBiDi();

driver = new FirefoxDriver(options);

Expand Down
6 changes: 3 additions & 3 deletions java/test/org/openqa/selenium/testing/drivers/Browser.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Capabilities getCapabilities() {
prefs.put("exited_cleanly", true);
options.setExperimentalOption("prefs", prefs);

options.setCapability("webSocketUrl", true);
options.enableBiDi();

return options;
}
Expand Down Expand Up @@ -90,7 +90,7 @@ public Capabilities getCapabilities() {
prefs.put("exited_cleanly", true);
options.setExperimentalOption("prefs", prefs);

options.setCapability("webSocketUrl", true);
options.enableBiDi();

return options;
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public Capabilities getCapabilities() {
options.addArguments("-headless");
}

options.setCapability("webSocketUrl", true);
options.enableBiDi();

return options;
}
Expand Down

0 comments on commit 0e8afac

Please sign in to comment.