OpenQA.Selenium.Remote.RemoteWebDriver.GetElementsFromResponse C# (CSharp) Method

GetElementsFromResponse() private method

Finds the elements that are in the response
private GetElementsFromResponse ( OpenQA.Selenium.Remote.Response response ) : ReadOnlyCollection
response OpenQA.Selenium.Remote.Response Response from the browser
return ReadOnlyCollection
        internal ReadOnlyCollection<IWebElement> GetElementsFromResponse(Response response)
        {
            List<IWebElement> toReturn = new List<IWebElement>();
            object[] elements = response.Value as object[];
            foreach (object elementObject in elements)
            {
                Dictionary<string, object> elementDictionary = elementObject as Dictionary<string, object>;
                if (elementDictionary != null)
                {
                    string id = (string)elementDictionary["ELEMENT"];
                    RemoteWebElement element = this.CreateElement(id);
                    toReturn.Add(element);
                }
            }

            return toReturn.AsReadOnly();
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Finds all child elements matching the given mechanism and value.
        /// </summary>
        /// <param name="mechanism">The mechanism by which to find the elements.</param>
        /// <param name="value">The value to use to search for the elements.</param>
        /// <returns>A collection of all of the <see cref="IWebElement">IWebElements</see> matchings the given criteria.</returns>
        protected ReadOnlyCollection <IWebElement> FindElements(string mechanism, string value)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("id", elementId);
            parameters.Add("using", mechanism);
            parameters.Add("value", value);
            Response commandResponse = Execute(DriverCommand.FindChildElements, parameters);

            return(driver.GetElementsFromResponse(commandResponse));
        }