Skip to content

Commit 5d4cfc1

Browse files
committed
[java] Improving error message for BiDi connection
Either when `webSocketUrl` is not set or the browser version does not support BiDi. Related to #13896 [skip ci]
1 parent 1e0cde1 commit 5d4cfc1

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,16 @@ public Optional<DevTools> maybeGetDevTools() {
347347
}
348348

349349
private Optional<BiDi> createBiDi(Optional<URI> biDiUri) {
350-
if (!biDiUri.isPresent()) {
350+
if (biDiUri.isEmpty()) {
351351
return Optional.empty();
352352
}
353353

354354
URI wsUri =
355355
biDiUri.orElseThrow(
356-
() -> new BiDiException("This version of Chromium driver does not support BiDi"));
356+
() ->
357+
new BiDiException(
358+
"Check if this browser version supports BiDi and if the 'webSocketUrl: true'"
359+
+ " capability is set."));
357360

358361
HttpClient.Factory clientFactory = HttpClient.Factory.createDefault();
359362
ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri);

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,16 @@ public DevTools getDevTools() {
354354
}
355355

356356
private Optional<BiDi> createBiDi(Optional<URI> biDiUri) {
357-
if (!biDiUri.isPresent()) {
357+
if (biDiUri.isEmpty()) {
358358
return Optional.empty();
359359
}
360360

361361
URI wsUri =
362362
biDiUri.orElseThrow(
363363
() ->
364-
new BiDiException("This version of Firefox or geckodriver does not support BiDi"));
364+
new BiDiException(
365+
"Check if this browser version supports BiDi and if the 'webSocketUrl: true'"
366+
+ " capability is set."));
365367

366368
HttpClient.Factory clientFactory = HttpClient.Factory.createDefault();
367369
ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri);
@@ -380,8 +382,10 @@ public Optional<BiDi> maybeGetBiDi() {
380382

381383
@Override
382384
public BiDi getBiDi() {
383-
if (!biDiUri.isPresent()) {
384-
throw new BiDiException("This version of Firefox or geckodriver does not support Bidi");
385+
if (biDiUri.isEmpty()) {
386+
throw new BiDiException(
387+
"Check if this browser version supports BiDi and if the 'webSocketUrl: true' capability"
388+
+ " is set.");
385389
}
386390

387391
return maybeGetBiDi()

0 commit comments

Comments
 (0)