Exemplo n.º 1
0
 private Response(Dictionary <string, object> rawResponse)
 {
     if (rawResponse.ContainsKey("sessionId") && rawResponse["sessionId"] != null)
     {
         this.responseSessionId = rawResponse["sessionId"].ToString();
     }
     if (rawResponse.ContainsKey("value"))
     {
         this.responseValue = rawResponse["value"];
     }
     if (rawResponse.ContainsKey("status"))
     {
         this.responseStatus = (WebDriverResult)Convert.ToInt32(rawResponse["status"], CultureInfo.InvariantCulture);
         return;
     }
     this.isSpecificationCompliant = true;
     if (!rawResponse.ContainsKey("value") && this.responseValue == null)
     {
         if (rawResponse.ContainsKey("capabilities"))
         {
             this.responseValue = rawResponse["capabilities"];
         }
         else
         {
             this.responseValue = rawResponse;
         }
     }
     if (rawResponse.ContainsKey("error"))
     {
         this.responseStatus = WebDriverError.ResultFromError(rawResponse["error"].ToString());
     }
 }
Exemplo n.º 2
0
        private Response(Dictionary <string, object> rawResponse)
        {
            if (rawResponse.ContainsKey("sessionId"))
            {
                if (rawResponse["sessionId"] != null)
                {
                    this.responseSessionId = rawResponse["sessionId"].ToString();
                }
            }

            if (rawResponse.ContainsKey("value"))
            {
                this.responseValue = rawResponse["value"];
            }

            // 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"
                // property of the response is the actual value we're interested in.
                if (rawResponse.ContainsKey("capabilities"))
                {
                    this.responseValue = rawResponse["capabilities"];
                }
                else
                {
                    this.responseValue = rawResponse;
                }
            }

            Dictionary <string, object> valueDictionary = this.responseValue as Dictionary <string, object>;

            if (valueDictionary != null)
            {
                // Special case code for the new session command. If the response contains
                // sessionId and capabilities properties, fix up the session ID and value members.
                if (valueDictionary.ContainsKey("sessionId"))
                {
                    this.responseSessionId = valueDictionary["sessionId"].ToString();
                    if (valueDictionary.ContainsKey("capabilities"))
                    {
                        this.responseValue = valueDictionary["capabilities"];
                    }
                    else
                    {
                        this.responseValue = valueDictionary["value"];
                    }
                }
                else if (valueDictionary.ContainsKey("error"))
                {
                    this.responseStatus = WebDriverError.ResultFromError(valueDictionary["error"].ToString());
                }
            }
        }
Exemplo n.º 3
0
 public static WebDriverResult ResultFromError(string error)
 {
     if (WebDriverError.resultMap == null)
     {
         WebDriverError.InitializeResultMap();
     }
     if (!WebDriverError.resultMap.ContainsKey(error))
     {
         error = "unsupported operation";
     }
     return(WebDriverError.resultMap[error]);
 }
Exemplo n.º 4
0
        private Response(Dictionary <string, object> rawResponse)
        {
            if (rawResponse.ContainsKey("sessionId"))
            {
                if (rawResponse["sessionId"] != null)
                {
                    this.responseSessionId = rawResponse["sessionId"].ToString();
                }
            }

            if (rawResponse.ContainsKey("value"))
            {
                this.responseValue = rawResponse["value"];
            }

            if (rawResponse.ContainsKey("status"))
            {
                this.responseStatus = (WebDriverResult)Convert.ToInt32(rawResponse["status"], CultureInfo.InvariantCulture);
            }
            else
            {
                // If the response does *not* have a "status" property, it
                // is compliant with the specification, which does not put
                // status in its responses.
                this.isSpecificationCompliant = true;

                // If the returned object does *not* have a "value" property
                // the response value should be the entirety of the response.
                if (!rawResponse.ContainsKey("value") && this.responseValue == null)
                {
                    // Special-case for the new session command, where the "capabilities"
                    // property of the response is the actual value we're interested in.
                    if (rawResponse.ContainsKey("capabilities"))
                    {
                        this.responseValue = rawResponse["capabilities"];
                    }
                    else
                    {
                        this.responseValue = rawResponse;
                    }
                }

                // Check for an error response by looking for an "error" property,
                // and if found, convert to a numeric status code.
                if (rawResponse.ContainsKey("error"))
                {
                    this.responseStatus = WebDriverError.ResultFromError(rawResponse["error"].ToString());
                }
            }
        }
Exemplo n.º 5
0
        private Response(Dictionary <string, object> rawResponse, int protocolSpecLevel)
        {
            if (rawResponse.ContainsKey("sessionId"))
            {
                if (rawResponse["sessionId"] != null)
                {
                    this.responseSessionId = rawResponse["sessionId"].ToString();
                }
            }

            if (rawResponse.ContainsKey("value"))
            {
                this.responseValue = rawResponse["value"];
            }

            if (protocolSpecLevel > 0)
            {
                // If the returned object does *not* have a "value" property,
                // then the responseValue member of the response will be null.
                if (this.responseValue == null)
                {
                    this.responseValue = rawResponse;
                }

                // Check for an error response by looking for an "error" property,
                // and if found, convert to a numeric status code.
                if (rawResponse.ContainsKey("error"))
                {
                    this.responseStatus = WebDriverError.ResultFromError(rawResponse["error"].ToString());
                }
            }
            else
            {
                if (rawResponse.ContainsKey("status"))
                {
                    this.responseStatus = (WebDriverResult)Convert.ToInt32(rawResponse["status"], CultureInfo.InvariantCulture);
                }

                // Special-case for the new session command, in the case where
                // the remote end is using the W3C dialect of the protocol.
                if (rawResponse.ContainsKey("capabilities"))
                {
                    this.responseValue = rawResponse["capabilities"];
                }
            }
        }