コード例 #1
0
 /// <summary>
 /// Gets a mechanism to find elements matching jQuery selector.
 /// </summary>
 /// <param name="selector">A string containing a selector expression.</param>
 /// <param name="context">A DOM Element, Document, or jQuery selector to use as context.</param>
 /// <param name="variable">A variable that has been assigned to jQuery.</param>
 /// <returns>A <see cref="JQuerySelector"/> object the driver can use to find the elements.</returns>
 public static JQuerySelector JQuerySelector(
     string selector,
     JQuerySelector context = null,
     string variable = "jQuery")
 {
     return new JQuerySelector(selector, context, variable, null);
 }
コード例 #2
0
 /// <summary>
 /// Gets a mechanism to find elements matching jQuery selector.
 /// </summary>
 /// <param name="selector">A string containing a selector expression.</param>
 /// <param name="context">A DOM Element, Document, or jQuery selector to use as context.</param>
 /// <param name="variable">A variable that has been assigned to jQuery.</param>
 /// <returns>A <see cref="JQuerySelector"/> object the driver can use to find the elements.</returns>
 public static JQuerySelector JQuerySelector(
     string selector,
     JQuerySelector context = null,
     string variable        = "jQuery")
 {
     return(new JQuerySelector(selector, context, variable, null));
 }
コード例 #3
0
 public void ShouldCreateCorrectSelector(JQuerySelector selector, string expectedSelector)
 {
     // Given
     // When
     // Then
     Assert.Equal(expectedSelector, selector.Selector);
 }
        public HospitalModel GetHospitalAddressFromHospitalList(string hospitalName)
        {
            JQuerySelector selector = new JQuerySelector("$('h3:contains(\"" + hospitalName + "\")').next()");
            string         text     = executioner.GetTextOnElement(selector).Trim();

            return(new HospitalModel()
            {
                HospitalName = hospitalName, CombinedAddressString = text
            });
        }
コード例 #5
0
        public void NavigateToExistingHosptialEdit(string hosptialName)
        {
            //This is a good example of where there isn't a good clean way to access an html element, and
            //you, as the test automator can't go to the devs and say 'add an id here'
            //In this example I'm trying to get the anchor tag for the Edit button for a specified hosptial

            //For example: $('div[ng-repeat*="hospital" h3:contains("Childrens") a')
            JQuerySelector script = new JQuerySelector("$('div[ng-repeat*=\"hospital\"] h3:contains(\"" + hosptialName + "\") a')");

            executioner.ClickElement(script, "Click the Edit button for " + hosptialName + " hospital", "Should be taken to the hospital edit screen");
            executioner.Pause(500);
        }
コード例 #6
0
ファイル: JQuery.cs プロジェクト: nickwong680/JQSelenium
        /// <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
            {
                try {
                    result = JavaScriptExecutor.ExecuteScript("return jQuery(jQuery.find(\"" + selector + "\"));");

                }
                catch (Exception) {
                    return null;
                }
            }


            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;
        }
 public void ShouldCreateCorrectSelector(JQuerySelector sut, string expectedSelector) =>
 sut.Selector.Should().Be(expectedSelector);
コード例 #8
0
 /// <summary>
 /// Gets a mechanism to find elements matching jQuery selector.
 /// </summary>
 /// <param name="selector">A string containing a selector expression.</param>
 /// <param name="context">A DOM Element, Document, or jQuery selector to use as context.</param>
 /// <param name="variable">A variable that has been assigned to jQuery.</param>
 /// <returns>A <see cref="JQuerySelector"/> object the driver can use to find the elements.</returns>
 public static JQuerySelector JQuerySelector(
     string selector, JQuerySelector context = null, string variable = "jQuery") =>
     new JQuerySelector(selector, context, variable);
コード例 #9
0
 public void ShouldCreateCorrectSelector(JQuerySelector selector, string expectedSelector)
 {
     // Arrange
     // Act
     // Assert
     selector.Selector.Should().Be(expectedSelector);
 }
 public void ShouldCreateCorrectSelector(JQuerySelector selector, string expectedSelector)
 {
     // Given
     // When
     // Then
     Assert.Equal(expectedSelector, selector.Selector);
 }