コード例 #1
0
        /// <summary>
        /// It will scroll till it finds the child element based on the given scrollable, selector and text. If you need something that is below that
        /// element, this will not work, as this will stop scrolling when it finds the element. In this case use the
        /// ScrollToFullView method.
        /// </summary>
        /// <param name="scrollable">Represents the Enum in Share class.</param>
        /// <param name="selector">Represents the Enum in Share class.</param>
        /// <param name="text">The text to match the element to be found.</param>
        /// <param name="allowScrollSearch">Set to true if scrolling is allow on the object.</param>
        public static AppiumWebElement ScrollToPartialView(Scrollable scrollable, Selector selector, string text, bool allowScrollSearch)
        {
            GlobalVar.AndroidDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(GlobalVar.TimeSpan);
            var uiAutomator = new UiScrollable().BuildChild(scrollable, selector, text, allowScrollSearch);

            try
            {
                return(GlobalVar.AndroidDriver.FindElementByAndroidUIAutomator(uiAutomator));
            }
            catch (Exception ex)
            {
                Assert.Fail("ScrollToPartialView threw an exception: " + ex.Message);
            }
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// It will scroll till it finds and shows the full element based on the given parameters.
        /// </summary>
        /// <param name="selector1">Represents the Enum in Share class.</param>
        /// <param name="attribute">The attribute to use, I recommend to use Id.</param>
        /// <param name="selector2">Represents the Enum in Share class.</param>
        /// <param name="text">The text to match the element to be found.</param>
        /// <param name="useFirst">Set to true if scrolling is allow on the object.</param>
        public static AppiumWebElement ScrollToFullView(Selector selector1, string attribute, Selector selector2, string text, bool useFirst)
        {
            GlobalVar.AndroidDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(GlobalVar.TimeSpan);
            var uiAutomator = new UiScrollable(selector1, attribute).Build(selector2, text, useFirst);

            try
            {
                return(GlobalVar.AndroidDriver.FindElementByAndroidUIAutomator(uiAutomator));
            }
            catch (Exception ex)
            {
                Assert.Fail("ScrollToFullView threw an exception: " + ex.Message);
            }
            return(null);
        }
コード例 #3
0
        /// <summary>
        /// It will scroll till it finds the element based on the given scrollable and value. If you need something that is below that
        /// element, this will not work, as this will stop scrolling when it finds the element. In this case use the
        /// ScrollToFullView method.
        /// </summary>
        /// <param name="scrollable">Represents the Enum in Share class.</param>
        /// <param name="value">The amount of swipes/flings to be done.</param>
        /// <returns>The <see cref="AppiumWebElement"/> of the element found</returns>


        /// <summary>
        /// It will scroll till it finds the element based on the given scrollable,steps and swipes. If you need something that is below that
        /// element, this will not work, as this will stop scrolling when it finds the element. In this case use the
        /// ScrollToFullView method.
        /// </summary>
        /// <param name="scrollable">Represents the Enum in Share class.</param>
        /// <param name="steps">The amount of steps to be done.</param>
        /// <param name="swipes">The amount of swipes to be done.</param>
        /// <returns>The <see cref="AppiumWebElement"/> of the element found</returns>
        public static AppiumWebElement ScrollToPartialView(Scrollable scrollable, int steps, int swipes)
        {
            GlobalVar.AndroidDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(GlobalVar.TimeSpan);
            var uiAutomator = new UiScrollable().Build(scrollable, steps, swipes);

            try
            {
                return(GlobalVar.AndroidDriver.FindElementByAndroidUIAutomator(uiAutomator));
            }
            catch (Exception ex)
            {
                Assert.Fail("ScrollToPartialView threw an exception: " + ex.Message);
            }
            return(null);
        }