diff --git a/java/src/org/openqa/selenium/chromium/ChromiumDriver.java b/java/src/org/openqa/selenium/chromium/ChromiumDriver.java index 6f282607c7166..7a87460878313 100644 --- a/java/src/org/openqa/selenium/chromium/ChromiumDriver.java +++ b/java/src/org/openqa/selenium/chromium/ChromiumDriver.java @@ -347,13 +347,16 @@ public Optional maybeGetDevTools() { } private Optional createBiDi(Optional biDiUri) { - if (!biDiUri.isPresent()) { + if (biDiUri.isEmpty()) { return Optional.empty(); } URI wsUri = biDiUri.orElseThrow( - () -> new BiDiException("This version of Chromium driver does not support BiDi")); + () -> + new BiDiException( + "Check if this browser version supports BiDi and if the 'webSocketUrl: true'" + + " capability is set.")); HttpClient.Factory clientFactory = HttpClient.Factory.createDefault(); ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri); diff --git a/java/src/org/openqa/selenium/firefox/FirefoxDriver.java b/java/src/org/openqa/selenium/firefox/FirefoxDriver.java index 36111d411c9a0..1745564ffdaf8 100644 --- a/java/src/org/openqa/selenium/firefox/FirefoxDriver.java +++ b/java/src/org/openqa/selenium/firefox/FirefoxDriver.java @@ -354,14 +354,16 @@ public DevTools getDevTools() { } private Optional createBiDi(Optional biDiUri) { - if (!biDiUri.isPresent()) { + if (biDiUri.isEmpty()) { return Optional.empty(); } URI wsUri = biDiUri.orElseThrow( () -> - new BiDiException("This version of Firefox or geckodriver does not support BiDi")); + new BiDiException( + "Check if this browser version supports BiDi and if the 'webSocketUrl: true'" + + " capability is set.")); HttpClient.Factory clientFactory = HttpClient.Factory.createDefault(); ClientConfig wsConfig = ClientConfig.defaultConfig().baseUri(wsUri); @@ -380,8 +382,10 @@ public Optional maybeGetBiDi() { @Override public BiDi getBiDi() { - if (!biDiUri.isPresent()) { - throw new BiDiException("This version of Firefox or geckodriver does not support Bidi"); + if (biDiUri.isEmpty()) { + throw new BiDiException( + "Check if this browser version supports BiDi and if the 'webSocketUrl: true' capability" + + " is set."); } return maybeGetBiDi()