Skip to content

Commit db435db

Browse files
committed
Handle the protocol handshake when remote end follows the spec
A recent change in the W3C spec required all responses to be sent back wrapped in a `value` field. This is wonderful, but makes the handshake fail. Fix that.
1 parent afd3232 commit db435db

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,18 @@ private Optional<Result> createSession(HttpClient client, StringBuilder params)
128128
Object w3cError = jsonBlob.get("error");
129129
Object ossStatus = jsonBlob.get("status");
130130
Map<String, ?> capabilities = null;
131+
132+
// The old geckodriver prior to 0.14 returned "value" as the thing containing the session id.
133+
// Later versions follow the (amended) w3c spec and return the capabilities in a field called
134+
// "value"
135+
if (value != null && value instanceof Map) {
136+
Map<?, ?> mappedValue = (Map<?, ?>) value;
137+
if (mappedValue.containsKey("value") && mappedValue.containsKey("sessionId")) {
138+
value = mappedValue.get("value");
139+
sessionId = mappedValue.get("sessionId");
140+
}
141+
}
142+
131143
if (value != null && value instanceof Map) {
132144
capabilities = (Map<String, ?>) value;
133145
} else if (value != null && value instanceof Capabilities) {

0 commit comments

Comments
 (0)