示例#1
0
        // ************ DATE 10/16/2020 ************
        // In charge of the instantiation of single Action functions
        // ************ --------------- ************
        #region SINGLE ACTION FUNCTIONS


        #region MOVE ACTIONS


        /// <summary>
        /// Emulates the swipe till the end of a specific element over the X & Y axis.
        /// </summary>
        /// <param name="className"> className of the element to swipe </param>
        /// <param name="direction"> represents the Enum in Share class </param>
        /// <param name="duration"> time to wait until swipe to position </param>
        public static void SwipeByClassName(string className, Direction direction = Direction.Up, int duration = 0)
        {
            ITouchAction action = BuildSingleAction();

            try
            {
                AppiumWebElement scrollView = GetControl.ByClass(className);

                var initialWidth  = scrollView.Size.Width - (scrollView.Size.Width - 5);
                var initialHeight = scrollView.Size.Height - (scrollView.Size.Height - 5);
                var centerWidth   = scrollView.Size.Width / 2;
                var centerHeight  = scrollView.Size.Height / 2;
                var endWidth      = scrollView.Size.Width - 5;
                var endHeight     = scrollView.Size.Height - 5;

                switch (direction)
                {
                case Direction.Up:
                    action.Press(scrollView, centerWidth, initialHeight).Wait(duration).MoveTo(scrollView, centerWidth, endHeight).Release().Perform();
                    break;

                case Direction.Down:
                    action.Press(scrollView, centerWidth, endHeight).Wait(duration).MoveTo(scrollView, centerWidth, initialHeight).Release().Perform();
                    break;

                case Direction.Left:
                    action.Press(scrollView, initialWidth, centerHeight).Wait(duration).MoveTo(scrollView, endWidth, centerHeight).Release().Perform();
                    break;

                case Direction.Right:
                    action.Press(scrollView, endWidth, centerHeight).Wait(duration).MoveTo(scrollView, initialWidth, centerHeight).Release().Perform();
                    break;
                }
            }
            catch (Exception ex)
            {
                Assert.Fail("SwipeByClassName threw an exception: " + ex.Message);
            }
        }
示例#2
0
        /// <summary>
        /// Swipe from an initial position to an ending position based on the parameters
        /// </summary>
        /// <param name="startX"> initial value on X axis </param>
        /// <param name="startY"> initial value on Y axis </param>
        /// <param name="endX"> ending value on X axis </param>
        /// <param name="endY"> ending value on Y axis </param>
        /// <param name="duration"> time to wait until swipe to position </param>
        public static void SwipeScreen(int startX, int startY, int endX, int endY, int duration = 0)
        {
            ITouchAction action = BuildSingleAction();

            try
            {
                action.Press(startX, startY).Wait(duration).MoveTo(endX, endY).Release().Perform();
            }
            catch (Exception ex)
            {
                Assert.Fail("SwipeScreen threw an exception: " + ex.Message);
            }
        }
示例#3
0
        /// <summary>
        /// Press over a specific element that will be found using it's classname.
        /// </summary>
        /// <param name="className"> classname of the element to be found </param>
        /// <param name="duration"> time to wait until swipe to position </param>
        public static void PressByClassName(string className, int duration = 0)
        {
            ITouchAction action = BuildSingleAction();

            try
            {
                AppiumWebElement element = GetControl.ByClass(className);
                action.Press(element).Wait(duration).Perform();
            }
            catch (Exception ex)
            {
                Assert.Fail("PressByClassName threw an exception: " + ex.Message);
            }
        }