コード例 #1
0
 /// <summary>
 ///   Determines if the JQuerySelector contains any elements
 /// </summary>
 /// <param name="comparer"> The jQuerySelector to compare with </param>
 /// <returns> True if both jQuerySelectors have the same elements.
 ///   <para> False they don't. </para>
 /// </returns>
 public bool HasSameElementsOf(JQuerySelector comparer)
 {
     for (int i = 0; i < _subset.Count; i++)
     {
         try
         {
             if (!_subset[i].Equals(comparer._subset[i]))
             {
                 return(false);
             }
         }
         catch
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #2
0
        /// <summary>
        ///   Finds all the elements filtered by the provided selector
        /// </summary>
        /// <param name="selector"> A string containing a selector expression to filter elements. </param>
        /// <returns> JQuerySelector containing JQueryTags each representing an element found in the DOM </returns>
        public JQuerySelector Find(string selector)
        {
            object         result;
            JQuerySelector jqs;

            if (JavaScriptExecutor is ChromeDriver)
            {
                result = JavaScriptExecutor.ExecuteScript("return jQuery(\"" + selector + "\");");
            }
            else
            {
                result = JavaScriptExecutor.ExecuteScript("return jQuery(jQuery.find(\"" + selector + "\"));");
            }


            if (result is ReadOnlyCollection <Object> )
            {
                if (JavaScriptExecutor is ChromeDriver)
                {
                    jqs = new JQuerySelector("jQuery(\"" + selector + "\")");
                }
                else
                {
                    jqs = new JQuerySelector("jQuery(jQuery.find(\"" + selector + "\"))");
                }
            }
            else
            {
                List <IWebElement> queryResultList = ObjectToWebElementList(result);

                if (JavaScriptExecutor is ChromeDriver)
                {
                    jqs = new JQuerySelector("jQuery(\"" + selector + "\")", queryResultList);
                }
                else
                {
                    jqs = new JQuerySelector("jQuery(jQuery.find(\"" + selector + "\"))", queryResultList);
                }
            }
            return(jqs);
        }