/// <summary> /// Finds an element using the element name. /// </summary> /// <param name="driver">The <see cref="IWebDriver"/> to use in finding the element.</param> /// <param name="use">The locator string to use.</param> /// <returns>An <see cref="IWebElement"/> that matches the locator string.</returns> public IWebElement Find(OpenQA.Selenium.IWebDriver driver, string use) { string[] parts = use.Split(new char[] { ' ' }); ReadOnlyCollection<IWebElement> allElements = driver.FindElements(By.Name(parts[0])); IList<IWebElement> filteredElements = new List<IWebElement>(allElements); for (int i = 1; i < parts.Length; i++) { IFilterFunction filterBy = this.GetFilterFunction(parts[i]); if (filterBy == null) { throw new SeleniumException(use + " not found. Cannot find filter for: " + parts[i]); } string filterValue = this.GetFilterValue(parts[i]); filteredElements = filterBy.FilterElements(allElements, filterValue); } if (filteredElements != null && filteredElements.Count > 0) { return filteredElements[0]; } throw new SeleniumException(use + " not found"); }