Grid: Better attempt to extract capabilities
Be a little more cautious about extracting capabilities when
in Grid.
@@ -63,14 +63,20 @@ public ExternalSessionKey extractSession() {
String json = getBody();
try {
JsonObject map = new JsonParser().parse(json).getAsJsonObject();
- // Current W3C has required / desired capabilities wrapped in a 'capabilites' object.
+ System.out.println("map = " + map);
+ // Current W3C has required / desired capabilities wrapped in a 'capabilities' object.
// This will need to be updated if/when https://github.com/w3c/webdriver/pull/327 gets merged
if (map.has("capabilities")) {
- return new JsonToBeanConverter().convert(Map.class, map.getAsJsonObject("capabilities").getAsJsonObject("desiredCapabilities"));
+ JsonObject outerCapabilities = map.getAsJsonObject("capabilities");
+ if (outerCapabilities.has("desiredCapabilities")) {
+ JsonObject desiredCapabilities = outerCapabilities.getAsJsonObject("desiredCapabilities");
+ System.out.println("desiredCapabilities = " + desiredCapabilities);
+ return new JsonToBeanConverter().convert(Map.class, desiredCapabilities);
+ }
}
JsonObject dc = map.get("desiredCapabilities").getAsJsonObject();
+ System.out.println("dc = " + dc);
return new JsonToBeanConverter().convert(Map.class, dc);
-
} catch (Exception e) {
throw new GridException("Cannot extract a capabilities from the request: " + json, e);
}
