Skip to content

Commit 128ec4e

Browse files
committed
Unwrap errors from a W3C compliant remote end in New Session
Should allow us to catch errors from an incorrectly created geckodriver session with geckodriver 0.15.
1 parent b6270ca commit 128ec4e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

java/client/src/org/openqa/selenium/remote/ProtocolHandshake.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,17 @@ private Optional<Result> createSession(HttpClient client, InputStream newSession
323323

324324
// The old geckodriver prior to 0.14 returned "value" as the thing containing the session id.
325325
// Later versions follow the (amended) w3c spec and return the capabilities in a field called
326-
// "value"
326+
// "value". The most recent versions of the spec contain any errors wrapped in a value object.
327+
// Pull that out if it exists.
327328
if (value != null && value instanceof Map) {
328329
Map<?, ?> mappedValue = (Map<?, ?>) value;
329330
if (mappedValue.containsKey("value") && mappedValue.containsKey("sessionId")) {
330331
value = mappedValue.get("value");
331332
sessionId = mappedValue.get("sessionId");
332333
}
334+
if (mappedValue.containsKey("error")) {
335+
w3cError = mappedValue.get("error");
336+
}
333337
}
334338

335339
if (value != null && value instanceof Map) {

0 commit comments

Comments
 (0)