Permalink
Browse files

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.
  • Loading branch information...
shs96c committed Feb 28, 2017
1 parent afd3232 commit db435db087cf958bc406e6823d7fd81eb292e212
Showing with 12 additions and 0 deletions.
  1. +12 −0 java/client/src/org/openqa/selenium/remote/ProtocolHandshake.java
@@ -128,6 +128,18 @@ public Result createSession(HttpClient client, Command command)
Object w3cError = jsonBlob.get("error");
Object ossStatus = jsonBlob.get("status");
Map<String, ?> capabilities = null;
// The old geckodriver prior to 0.14 returned "value" as the thing containing the session id.
// Later versions follow the (amended) w3c spec and return the capabilities in a field called
// "value"
if (value != null && value instanceof Map) {
Map<?, ?> mappedValue = (Map<?, ?>) value;
if (mappedValue.containsKey("value") && mappedValue.containsKey("sessionId")) {
value = mappedValue.get("value");
sessionId = mappedValue.get("sessionId");
}
}
if (value != null && value instanceof Map) {
capabilities = (Map<String, ?>) value;
} else if (value != null && value instanceof Capabilities) {

0 comments on commit db435db

Please sign in to comment.