Account for W3C new session response with 'value' property in .NET
@@ -80,6 +80,9 @@ private Response(Dictionary<string, object> rawResponse)
// If the returned object does *not* have a "value" property
// the response value should be the entirety of the response.
+ // TODO: Remove this if statement altogether; there should
+ // never be a spec-compliant response that does not contain a
+ // value property.
if (!rawResponse.ContainsKey("value") && this.responseValue == null)
{
// Special-case for the new session command, where the "capabilities"
@@ -94,6 +97,15 @@ private Response(Dictionary<string, object> rawResponse)
}
}
+ // Special case code for the new session command. If the response contains
+ // sessionId and capabilities properties, fix up the session ID and
+ Dictionary<string, object> valueDictionary = this.responseValue as Dictionary<string, object>;
+ if (valueDictionary != null && valueDictionary.ContainsKey("sessionId") && valueDictionary.ContainsKey("capabilities"))
+ {
+ this.responseSessionId = valueDictionary["sessionId"].ToString();
+ this.responseValue = valueDictionary["capabilities"];
+ }
+
// Check for an error response by looking for an "error" property,
// and if found, convert to a numeric status code.
if (rawResponse.ContainsKey("error"))
