From 5fc660e46a0e33b3bd9b054c31a05d4ffcd98e1c Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 13 Oct 2025 14:24:40 +0200 Subject: [PATCH 1/2] [java] Rescuing the remote cause for session creation errors Fixes #16388 --- java/src/org/openqa/selenium/remote/RemoteWebDriver.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java index 1dc42ed132c55..1be637ed94e5e 100644 --- a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java +++ b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java @@ -572,10 +572,14 @@ protected Response execute(CommandPayload payload) { if (e instanceof SessionNotCreatedException) { toThrow = (WebDriverException) e; } else { + // When this exception comes from a remote end, the real cause is usually hidden in the + // cause. Let's try to rescue it and display it at the top level. + String cause = e.getCause() != null ? e.getCause().getMessage() : ""; toThrow = new SessionNotCreatedException( "Possible causes are invalid address of the remote server or browser start-up" - + " failure.", + + " failure. " + + cause, e); } } else if (e instanceof WebDriverException) { From aa2e084c401be10fe33e2e6ff1386ed0e2ce0883 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 13 Oct 2025 17:17:01 +0200 Subject: [PATCH 2/2] Code improvement, thanks to @valfirst --- java/src/org/openqa/selenium/remote/RemoteWebDriver.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java index 1be637ed94e5e..deca89f60595d 100644 --- a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java +++ b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java @@ -574,11 +574,11 @@ protected Response execute(CommandPayload payload) { } else { // When this exception comes from a remote end, the real cause is usually hidden in the // cause. Let's try to rescue it and display it at the top level. - String cause = e.getCause() != null ? e.getCause().getMessage() : ""; + String cause = e.getCause() != null ? " " + e.getCause().getMessage() : ""; toThrow = new SessionNotCreatedException( "Possible causes are invalid address of the remote server or browser start-up" - + " failure. " + + " failure." + cause, e); }