/// <summary> /// Find a specified element by selector /// </summary> /// <param name="selector">selector to use to locate element</param> /// <returns>element or throws an exception</returns> public virtual IWebElement FindElement(string selector) { if (selector == null) { throw new ArgumentNullException("selector"); } switch (_fixture.Configuration.Selector) { case SelectorAlgorithm.JQuery: return(_fixture.Driver.FindElement(Using.JQuery(selector))); case SelectorAlgorithm.CSS: return(_fixture.Driver.FindElement(By.CssSelector(selector))); case SelectorAlgorithm.XPath: return(_fixture.Driver.FindElement(By.XPath(selector))); case SelectorAlgorithm.Auto: return(_fixture.Driver.FindElement(Using.Auto(selector))); default: throw new Exception("Unknown SelectorAlgorithm " + _fixture.Configuration.Selector); } }
/// <summary> /// Finds all elements matching the criteria. /// </summary> /// <param name="context">An <see cref="T:OpenQA.Selenium.ISearchContext"/> object to use to search for the elements.</param> /// <returns> /// A <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1"/> of all <see cref="T:OpenQA.Selenium.IWebElement">WebElements</see> /// matching the current criteria, or an empty list if nothing matches. /// </returns> public override ReadOnlyCollection <IWebElement> FindElements(ISearchContext context) { By by = null; if (_selector.StartsWith("//")) { by = XPath(_selector); } else { by = IsJavaScriptEnabled(context, _jQueryTest) ? Using.JQuery(_selector) : CssSelector(_selector); } return(context.FindElements(by)); }