diff --git a/java/src/org/openqa/selenium/devtools/CdpEndpointFinder.java b/java/src/org/openqa/selenium/devtools/CdpEndpointFinder.java index 75a1f786def1c..ef4d131aca6e6 100644 --- a/java/src/org/openqa/selenium/devtools/CdpEndpointFinder.java +++ b/java/src/org/openqa/selenium/devtools/CdpEndpointFinder.java @@ -25,6 +25,8 @@ import org.openqa.selenium.remote.http.HttpRequest; import org.openqa.selenium.remote.http.HttpResponse; +import java.io.IOException; +import java.io.UncheckedIOException; import java.net.URI; import java.net.URISyntaxException; import java.util.Map; @@ -48,7 +50,13 @@ public static Optional getCdpEndPoint(HttpClient.Factory clientFactory, URI ClientConfig config = ClientConfig.defaultConfig().baseUri(reportedUri); HttpClient client = clientFactory.createClient(config); - HttpResponse res = client.execute(new HttpRequest(GET, "/json/version")); + HttpResponse res; + try { + res = client.execute(new HttpRequest(GET, "/json/version")); + } catch (UncheckedIOException e) { + LOG.warning("Unable to connect to determine websocket url: " + e.getMessage()); + return Optional.empty(); + } if (res.getStatus() != HTTP_OK) { return Optional.empty(); }