public override ReadOnlyCollection <IWebElement> FindElements(ISearchContext context) { var rawCollection = Execute <object>(context, JavaScript.Get()); var collection = rawCollection as ReadOnlyCollection <IWebElement>; //Unlike FindElement, FindElements does not throw an exception if no elements are found //and instead returns an empty list return(collection ?? (new ReadOnlyCollection <IWebElement>(new List <IWebElement>()))); }
public override IWebElement FindElement(ISearchContext context) { var element = Execute <IWebElement>(context, JavaScript.Get(0)); if (element != null) { return(element); } throw new NoSuchElementException("No element found with JavaScript command: " + JavaScript.Statement); }