Provides a mechanism to get elements off the page for test
Inheritance: RenderedRemoteWebElement, ILocatable, IFindsByCssSelector
Beispiel #1
0
        private object ParseJavaScriptReturnValue(object responseValue)
        {
            object returnValue = null;

            Dictionary<string, object> result = responseValue as Dictionary<string, object>;
            object[] resultAsArray = responseValue as object[];
            if (result != null)
            {
                string type = (string)result["type"];
                if (type != "NULL")
                {
                    if (type == "ELEMENT")
                    {
                        string[] parts = result["value"].ToString().Split(new string[] { "/" }, StringSplitOptions.None);
                        string elementId = parts[parts.Length - 1];
                        ChromeWebElement element = new ChromeWebElement(this, elementId);
                        returnValue = element;
                    }
                    else if (result["value"] is double)
                    {
                        double resultValue = (double)result["value"];
                        long longValue;
                        bool isLong = long.TryParse(resultValue.ToString(CultureInfo.InvariantCulture), out longValue);
                        if (isLong)
                        {
                            returnValue = longValue;
                        }
                        else
                        {
                            returnValue = resultValue;
                        }
                    }
                    else
                    {
                        returnValue = result["value"];
                    }
                }
            }
            else if (resultAsArray != null)
            {
                List<object> returnList = new List<object>();
                foreach (object item in resultAsArray)
                {
                    returnList.Add(ParseJavaScriptReturnValue(item));
                }

                returnValue = returnList;
            }

            return returnValue;
        }
Beispiel #2
0
 /// <summary>
 /// Finds all Child elements of an Element
 /// </summary>
 /// <param name="parent">Parent element</param>
 /// <param name="by">By Mechanism</param>
 /// <param name="search">Search String</param>
 /// <returns>Collection of elements that meet the criteria</returns>
 public ReadOnlyCollection<IWebElement> FindChildElements(ChromeWebElement parent, string by, string search)
 {
     return GetElementsFrom(Execute(DriverCommand.FindChildElements, parent, by, search));
 }