/// <summary>
        /// Overloads the FindElement function to include support for the jQuery selector class
        /// </summary>
        public static string GetHtml(this RemoteWebDriver driver, By.jQueryBy by)
        {
            //First make sure we can use jQuery functions
            driver.LoadjQuery();

            //Execute the jQuery selector as a script
            var html = driver.ExecuteScript("return jQuery" + by.Selector + ".html()").ToString();

            return(html);
        }
        public static int CountNumberOfElements(this IWebDriver browser, By.jQueryBy by, Func <IWebElement, Boolean> predicate = null)
        {
            var elements = browser.FindElements(by);

            if (predicate == null)
            {
                return(elements.Count);
            }

            return(elements.Where(predicate).Count());
        }
        /// <summary>
        /// Overloads the FindElement function to include support for the jQuery selector class
        /// </summary>
        public static IWebElement FindElementByjQuery(this IWebDriver driver, By.jQueryBy by)
        {
            var browser = (RemoteWebDriver)driver;

            //First make sure we can use jQuery functions
            browser.LoadjQuery();

            //Execute the jQuery selector as a script
            IWebElement element = browser.ExecuteScript("return jQuery" + by.Selector + ".get(0)") as IWebElement;

            if (element != null)
            {
                return(element);
            }
            throw new NoSuchElementException("No element found with jQuery command: jQuery" + @by.Selector);
        }
 /// <summary>
 /// Gets the HTML using jQuery selector class
 /// </summary>
 public static string GetHtml(this IWebDriver driver, By.jQueryBy by)
 {
     return((driver as RemoteWebDriver).GetHtml(by));
 }
 /// <summary>
 /// Overloads the FindElement function to include support for the jQuery selector class
 /// </summary>
 public static IWebElement FindElement(this IWebDriver driver, By.jQueryBy by)
 {
     return((driver as RemoteWebDriver).FindElement(by));
 }
        /// <summary>
        /// Overloads the FindElements function to include support for the jQuery selector class
        /// </summary>
        public static ReadOnlyCollection <IWebElement> FindElements(this RemoteWebDriver driver, By.jQueryBy by)
        {
            //First make sure we can use jQuery functions
            driver.LoadjQuery();

            //Execute the jQuery selector as a script
            ReadOnlyCollection <IWebElement> collection = driver.ExecuteScript("return jQuery" + by.Selector + ".get()") as ReadOnlyCollection <IWebElement>;

            //Unlike FindElement, FindElements does not throw an exception if no elements are found
            //and instead returns an empty list
            if (collection == null)
            {
                collection = new ReadOnlyCollection <IWebElement>(new List <IWebElement>()); //empty list
            }
            return(collection);
        }
 /// <summary>
 /// Overloads the FindElement function to include support for the jQuery selector class
 /// </summary>
 public static ReadOnlyCollection <IWebElement> FindElements(this IWebDriver driver, By.jQueryBy by)
 {
     return((driver as RemoteWebDriver).FindElements(by));
 }