Beispiel #1
0
        /// <summary>
        ///     Finds all <see cref="NgWebElement" />s within the current context
        ///     using the given mechanism.
        /// </summary>
        /// <param name="by">The locating mechanism to use.</param>
        /// <returns>
        ///     A <see cref="ReadOnlyCollection{T}" /> of all <see cref="NgWebElement" />s
        ///     matching the current criteria, or an empty list if nothing matches.
        /// </returns>
        public ReadOnlyCollection <NgWebElement> FindElements(By by)
        {
            if (by is JavaScriptBy scriptBy)
            {
                scriptBy.AdditionalScriptArguments = new object[] { NgDriver.RootElement, WrappedElement }
            }
            ;
            NgDriver.WaitForAngular();
            return(new ReadOnlyCollection <NgWebElement>(WrappedElement.FindElements(by)
                                                         .Select(e => new NgWebElement(NgDriver, e)).ToList()));
        }

        IWebElement ISearchContext.FindElement(By by)
        {
            return(FindElement(by));
        }

        ReadOnlyCollection <IWebElement> ISearchContext.FindElements(By by)
        {
            if (by is JavaScriptBy scriptBy)
            {
                scriptBy.AdditionalScriptArguments = new object[] { NgDriver.RootElement, WrappedElement }
            }
            ;
            NgDriver.WaitForAngular();
            return(new ReadOnlyCollection <IWebElement>(WrappedElement.FindElements(by)
                                                        .Select(e => (IWebElement) new NgWebElement(NgDriver, e)).ToList()));
        }

        #endregion
    }
}
Beispiel #2
0
 /// <summary>
 ///     Finds the first <see cref="NgWebElement" /> using the given mechanism.
 /// </summary>
 /// <param name="by">The locating mechanism to use.</param>
 /// <returns>The first matching <see cref="NgWebElement" /> on the current context.</returns>
 /// <exception cref="NoSuchElementException">If no element matches the criteria.</exception>
 public NgWebElement FindElement(By by)
 {
     if (by is JavaScriptBy scriptBy)
     {
         scriptBy.AdditionalScriptArguments = new object[] { NgDriver.RootElement, WrappedElement }
     }
     ;
     NgDriver.WaitForAngular();
     return(new NgWebElement(NgDriver, WrappedElement.FindElement(by)));
 }
Beispiel #3
0
        public void TestModulo()
        {
            const string firstNumber    = "5252";
            const string secondNumber   = "2525";
            const string expectedResult = "202";

            _calculatorPage.CalculateNumbers(firstNumber, secondNumber, MathematicalOperation.MODULO);
            NgDriver.WaitForAngular();

            Assert.AreEqual(expectedResult, _calculatorPage.GetResult());
        }
Beispiel #4
0
        public void TestMultiplication()
        {
            const string firstNumber    = "5252";
            const string secondNumber   = "2525";
            const string expectedResult = "13261300";

            _calculatorPage.CalculateNumbers(firstNumber, secondNumber, MathematicalOperation.MULTIPLICATION);
            NgDriver.WaitForAngular();

            Assert.AreEqual(expectedResult, _calculatorPage.GetResult());
        }
Beispiel #5
0
        public void TestSubtraction()
        {
            const string firstNumber    = "5252";
            const string secondNumber   = "2525";
            const string expectedResult = "2727";

            _calculatorPage.CalculateNumbers(firstNumber, secondNumber, MathematicalOperation.SUBTRACTION);
            NgDriver.WaitForAngular();

            Assert.AreEqual(expectedResult, _calculatorPage.GetResult());
        }
Beispiel #6
0
 /// <summary>
 ///     Move a single "item" forward in the browser's history.
 /// </summary>
 public void Forward()
 {
     NgDriver.WaitForAngular();
     WrappedNavigation.Forward();
 }
Beispiel #7
0
 /// <summary>
 ///     Move back a single entry in the browser's history.
 /// </summary>
 public void Back()
 {
     NgDriver.WaitForAngular();
     WrappedNavigation.Back();
 }
Beispiel #8
0
 /// <summary>
 ///     Evaluates the expression as if it were on the scope of the current element.
 /// </summary>
 /// <param name="expression">The expression to evaluate.</param>
 /// <returns>The expression evaluated by Angular.</returns>
 public object Evaluate(string expression)
 {
     NgDriver.WaitForAngular();
     return(NgDriver.ExecuteScript(ClientSideScripts.Evaluate, WrappedElement, expression));
 }
Beispiel #9
0
 /// <summary>
 ///     Submits this element to the web server.
 /// </summary>
 public void Submit()
 {
     NgDriver.WaitForAngular();
     WrappedElement.Submit();
 }
Beispiel #10
0
 /// <summary>
 ///     Simulates typing text into the element.
 /// </summary>
 public void SendKeys(string text)
 {
     NgDriver.WaitForAngular();
     WrappedElement.SendKeys(text);
 }
Beispiel #11
0
 /// <summary>
 ///     Gets the value of a CSS property of this element.
 /// </summary>
 public string GetCssValue(string propertyName)
 {
     NgDriver.WaitForAngular();
     return(WrappedElement.GetCssValue(propertyName));
 }
Beispiel #12
0
 /// <summary>
 ///     Gets the value of the specified attribute for this element.
 /// </summary>
 public string GetAttribute(string attributeName)
 {
     NgDriver.WaitForAngular();
     return(WrappedElement.GetAttribute(attributeName));
 }
Beispiel #13
0
 /// <summary>
 ///     Clicks this element.
 /// </summary>
 public void Click()
 {
     NgDriver.WaitForAngular();
     WrappedElement.Click();
 }