Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] Add convenience for enabling BiDi #14029

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading