Ejemplo n.º 1
0
        public void MultiActionTestCase()
        {
            IOSDriver <IWebElement> driver  = new IOSDriver <IWebElement>(defaultUri, capabilities);
            RequestProcessor        re      = setupMultiAction();
            IWebElement             element = driver.FindElementByIosUIAutomation(".elements()");

            MultiAction m = new MultiAction(driver);

            m.Perform();
            Assert.AreEqual(re.inputData, "");

            TouchAction a1 = new TouchAction(driver);

            a1
            .Press(element, 100, 100)
            .Wait(1000)
            .Release();
            m.Add(a1);
            m.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[[{\"action\":\"press\",\"options\":{\"element\":\"5\",\"x\":100,\"y\":100}},{\"action\":\"wait\",\"options\":{\"ms\":1000}},{\"action\":\"release\"}]]}");

            TouchAction a2 = new TouchAction(driver);

            a2
            .Tap(100, 100)
            .MoveTo(element);
            m.Add(a2);
            m.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[[{\"action\":\"press\",\"options\":{\"element\":\"5\",\"x\":100,\"y\":100}},{\"action\":\"wait\",\"options\":{\"ms\":1000}},{\"action\":\"release\"}],[{\"action\":\"tap\",\"options\":{\"x\":100,\"y\":100}},{\"action\":\"moveTo\",\"options\":{\"element\":\"5\"}}]]}");
        }
        public void CheckTap(IPerformsTouchActions performer)
        {
            TouchAction t = new TouchAction(performer);

            t.Tap(accessibility);
            t.Perform();

            MultiAction m = new MultiAction(performer);

            m.Add(new TouchAction().Tap(customView));
            m.Add(new TouchAction(performer).Tap(clickable));
            m.Perform();
        }
Ejemplo n.º 3
0
        public void CheckTap(IPerformsTouchActions performer)
        {
            var t = new TouchAction(performer);

            t.Tap(_accessibility);
            t.Perform();

            var m = new MultiAction(performer);

            m.Add(new TouchAction(performer).Tap(_customView));
            m.Add(new TouchAction(performer).Tap(_clickable));
            m.Perform();
        }
        public void SequentalMultiActionTestCase()
        {
            string originalActivity      = driver.CurrentActivity;
            IList <AppiumWebElement> els = driver.FindElementsByClassName("android.widget.TextView");
            MultiAction multiTouch       = new MultiAction(driver);

            TouchAction tap1 = new TouchAction(driver);

            tap1.Press(els[5]).Wait(1500).Release();

            multiTouch.Add(tap1).Add(tap1).Perform();

            Thread.Sleep(2500);
            els = driver.FindElementsByClassName("android.widget.TextView");

            TouchAction tap2 = new TouchAction(driver);

            tap2.Press(els[1]).Wait(1500).Release();

            MultiAction multiTouch2 = new MultiAction(driver);

            multiTouch2.Add(tap2).Add(tap2).Perform();

            Thread.Sleep(2500);
            Assert.AreNotEqual(originalActivity, driver.CurrentActivity);
        }
Ejemplo n.º 5
0
        public virtual void SwipeToDelete(string automationId, int index)
        {
            var item  = Driver.FindElement(ByAutomationId(automationId));
            var width = Driver.Manage().Window.Size.Width;

            var act   = new TouchAction(Driver);
            var press = act.Press(item, width, item.Location.Y);
            var move  = act.MoveTo(item, 0, item.Location.Y);
            var lift  = act.Release();

            var action = new MultiAction(Driver);

            action.Add(press);
            action.Add(move);
            action.Add(lift);
            action.Perform();
        }
        public void Tap(IPerformsTouchActions multitouchPerformer, int fingers, IWebElement webElement)
        {
            MultiAction multiTouch = new MultiAction(multitouchPerformer);

            for (int i = 0; i < fingers; i++)
            {
                multiTouch.Add(new TouchAction(multitouchPerformer).Tap(webElement));
            }

            multiTouch.Perform();
        }
        public void Tapxy(IPerformsTouchActions multitouchPerformer, int fingers, int x, int y)
        {
            MultiAction multiTouch = new MultiAction(multitouchPerformer);

            for (int i = 0; i < fingers; i++)
            {
                multiTouch.Add(new TouchAction(multitouchPerformer).Tap(x, y));
            }

            multiTouch.Perform();
        }
Ejemplo n.º 8
0
        public void Tap(int fingers, int x, int y, int duration)
        {
            MultiAction multiTouch = new MultiAction(this);

            for (int i = 0; i < fingers; i++)
            {
                multiTouch.Add(new TouchAction(this).Press(x, y).Wait(duration).Release());
            }

            multiTouch.Perform();
        }
        /// <summary>
        /// Convenience method for tapping a position on the screen
        /// </summary>
        /// <param name="fingers">number of fingers/appendages to tap with</param>
        /// <param name="x">x coordinate</param>
        /// <param name="y">y coordinate</param>
        /// <param name="duration">how long between pressing down, and lifting fingers/appendages</param>
        public void Tap(int fingers, int x, int y, int duration)
        {
            MultiAction multiTouch = new MultiAction(this);

            for (int i = 0; i < fingers; i++)
            {
                multiTouch.Add(CreateTap(x, y, duration));
            }

            multiTouch.Perform();
        }
        /// <summary>
        /// Convenience method for tapping the center of an element on the screen
        /// </summary>
        /// <param name="fingers">number of fingers/appendages to tap with</param>
        /// <param name="element">element to tap</param>
        /// <param name="duration">how long between pressing down, and lifting fingers/appendages</param>
        public void Tap(int fingers, IWebElement element, int duration)
        {
            MultiAction multiTouch = new MultiAction(this);

            for (int i = 0; i < fingers; i++)
            {
                multiTouch.Add(CreateTap(element, duration));
            }

            multiTouch.Perform();
        }
Ejemplo n.º 11
0
        public void MultiActionTestCase()
        {
            IWebElement  el = driver.FindElementByAccessibilityId("ComputeSumButton");
            ITouchAction a1 = new TouchAction(driver);

            a1.Tap(el, 10, 10);
            ITouchAction a2 = new TouchAction(driver);

            a2.Tap(el);
            IMultiAction m = new MultiAction(driver);

            m.Add(a1).Add(a2);
            m.Perform();
        }
        /// <summary>
        /// Convenience method for "zooming in" on an element on the screen.
        /// "zooming in" refers to the action of two appendages Pressing the screen and sliding away from each other.
        /// NOTE:
        /// driver convenience method slides touches away from the element, if driver would happen to place one of them
        /// off the screen, appium will return an outOfBounds error. In driver case, revert to using the MultiAction api
        /// instead of driver method.
        /// <param name="el">The element to pinch</param>
        /// </summary>
        public void Zoom(IWebElement el)
        {
            MultiAction multiTouch = new MultiAction(this);

            Size  dimensions = el.Size;
            Point upperLeft  = el.Location;
            Point center     = new Point(upperLeft.X + dimensions.Width / 2, upperLeft.Y + dimensions.Height / 2);
            int   yOffset    = center.Y - upperLeft.Y;

            ITouchAction action0 = new TouchAction(this).Press(el).MoveTo(el, 0, -yOffset).Release();
            ITouchAction action1 = new TouchAction(this).Press(el).MoveTo(el, 0, yOffset).Release();

            multiTouch.Add(action0).Add(action1);

            multiTouch.Perform();
        }
        public void SingleMultiActionTestCase()
        {
            IList <AppiumWebElement> els = driver.FindElementsByClassName("android.widget.TextView");
            var loc1 = els[7].Location;
            AppiumWebElement target = els[1];
            var loc2 = target.Location;

            TouchAction swipe = new TouchAction(driver);

            swipe.Press(loc1.X, loc1.Y).Wait(1000)
            .MoveTo(loc2.X, loc2.Y).Release();

            MultiAction multiAction = new MultiAction(driver);

            multiAction.Add(swipe).Perform();
            Assert.AreNotEqual(loc2.Y, target.Location.Y);
        }
 public static void Unshare(string shareWith)
 {
     try
     {
         AndroidElement dragItem = (AndroidElement)ShareWithList.GetInternalElement().FindElementByName(shareWith);
         AndroidElement dropItem = TeamList.GetInternalElement();
         TouchAction    action   = new TouchAction(Appium.Instance.Driver);
         action.Press(dragItem).Wait(1500).MoveTo(dragItem).Wait(1500).MoveTo(dropItem).Wait(1500).Release();
         MultiAction multi = new MultiAction(Appium.Instance.Driver);
         multi.Add(action).Perform();
         ConsoleMessage.Pass(String.Format("{0}. Unshare. Drag user with name: {1} and drop to team", ActivityName, shareWith));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't unshare. Can't drag user with name: {1} and drop to team", ActivityName, shareWith), ex);
         throw;
     }
 }
Ejemplo n.º 15
0
 public static void SwapProperty(string prop1, string prop2)
 {
     try
     {
         AndroidElement dragItem = GetPropertyItem(prop1);
         AndroidElement dropItem = GetPropertyItem(prop2);
         TouchAction    action   = new TouchAction(Appium.Instance.Driver);
         action.Press(dragItem).Wait(1500).MoveTo(dragItem).Wait(1500).MoveTo(dropItem).Wait(1500).Release();
         MultiAction multi = new MultiAction(Appium.Instance.Driver);
         multi.Add(action).Perform();
         ConsoleMessage.Pass(
             String.Format("{0}. Swap property. Drag property: {1} and drop to property: {2}", ActivityName, prop1, prop2));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(
             String.Format("{0}. Can't swap property. Drag property: {1} and drop to property: {2}", ActivityName, prop1, prop2), ex);
         throw;
     }
 }
Ejemplo n.º 16
0
        public void MultiActionTestCase()
        {
            driver.FindElementById("TextField1").Clear();
            driver.FindElementById("TextField1").SendKeys("2");
            driver.FindElementById("TextField2").Clear();
            driver.FindElementById("TextField2").SendKeys("4");
            IWebElement  el = driver.FindElementByAccessibilityId("ComputeSumButton");
            ITouchAction a1 = new TouchAction(driver);

            a1.Tap(el, 10, 10);
            ITouchAction a2 = new TouchAction(driver);

            a2.Tap(el);
            IMultiAction m = new MultiAction(driver);

            m.Add(a1).Add(a2);
            m.Perform();
            const string str = "6";

            Assert.AreEqual(driver.FindElementByXPath("//*[@name = \"Answer\"]").Text, str);
        }
Ejemplo n.º 17
0
 public static void RemoveUserFromTeam(string userName)
 {
     try
     {
         AndroidElement dragItem = TeamMemberList.FindElement(userName);
         AndroidElement dropItem = UserList.GetInternalElement();
         TouchAction    action   = new TouchAction(Appium.Instance.Driver);
         action.Press(dragItem).Wait(1500).MoveTo(dragItem).Wait(1500).MoveTo(dropItem).Wait(1500).Release();
         MultiAction multi = new MultiAction(Appium.Instance.Driver);
         multi.Add(action).Perform();
         ConsoleMessage.Pass(String.Format("{0}. Drag user with name: {1} and drop to users list", ActivityName,
                                           userName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(
             String.Format("{0}. Can't drag user with name: {1} and drop to users list", ActivityName, userName),
             ex);
         throw;
     }
 }
        /// <summary>
        /// Convenience method for "zooming in" on an element on the screen.
        /// "zooming in" refers to the action of two appendages Pressing the screen and sliding away from each other.
        /// NOTE:
        /// driver convenience method slides touches away from the element, if driver would happen to place one of them
        /// off the screen, appium will return an outOfBounds error. In driver case, revert to using the MultiAction api
        /// instead of driver method.
        /// <param name="x">x coordinate to terminate the zoom on</param>
        /// <param name="y">y coordinate to terminate the zoom on></param>
        /// </summary>
        public void Zoom(int x, int y)
        {
            MultiAction multiTouch = new MultiAction(this);

            int scrHeight = Manage().Window.Size.Height;
            int yOffset   = 100;

            if (y - 100 < 0)
            {
                yOffset = y;
            }
            else if (y + 100 > scrHeight)
            {
                yOffset = scrHeight - y;
            }

            ITouchAction action0 = new TouchAction(this).Press(x, y).MoveTo(0, -yOffset).Release();
            ITouchAction action1 = new TouchAction(this).Press(x, y).MoveTo(0, yOffset).Release();

            multiTouch.Add(action0).Add(action1);

            multiTouch.Perform();
        }
        public void DrawSmileyTestCase()
        {
            driver.FindElementByName("Graphics").Click();
            var el = FindTouchPaint();

            el.Click();
            Thread.Sleep(5000);
            ITouchAction a1 = new TouchAction();

            a1.Press(140, 100).Release();
            ITouchAction a2 = new TouchAction();

            a2.Press(250, 100).Release();
            ITouchAction smile = new TouchAction();

            smile
            .Press(110, 200)
            .MoveTo(1, 1)
            .MoveTo(1, 1)
            .MoveTo(1, 1)
            .MoveTo(1, 1)
            .MoveTo(1, 1)
            .MoveTo(2, 1)
            .MoveTo(2, 1)
            .MoveTo(2, 1)
            .MoveTo(2, 1)
            .MoveTo(2, 1)
            .MoveTo(3, 1)
            .MoveTo(3, 1)
            .MoveTo(3, 1)
            .MoveTo(3, 1)
            .MoveTo(3, 1)
            .MoveTo(4, 1)
            .MoveTo(4, 1)
            .MoveTo(4, 1)
            .MoveTo(4, 1)
            .MoveTo(4, 1)
            .MoveTo(5, 1)
            .MoveTo(5, 1)
            .MoveTo(5, 1)
            .MoveTo(5, 1)
            .MoveTo(5, 1)
            .MoveTo(5, 0)
            .MoveTo(5, 0)
            .MoveTo(5, 0)
            .MoveTo(5, 0)
            .MoveTo(5, 0)
            .MoveTo(5, 0)
            .MoveTo(5, 0)
            .MoveTo(5, 0)
            .MoveTo(5, -1)
            .MoveTo(5, -1)
            .MoveTo(5, -1)
            .MoveTo(5, -1)
            .MoveTo(5, -1)
            .MoveTo(4, -1)
            .MoveTo(4, -1)
            .MoveTo(4, -1)
            .MoveTo(4, -1)
            .MoveTo(4, -1)
            .MoveTo(3, -1)
            .MoveTo(3, -1)
            .MoveTo(3, -1)
            .MoveTo(3, -1)
            .MoveTo(3, -1)
            .MoveTo(2, -1)
            .MoveTo(2, -1)
            .MoveTo(2, -1)
            .MoveTo(2, -1)
            .MoveTo(2, -1)
            .MoveTo(1, -1)
            .MoveTo(1, -1)
            .MoveTo(1, -1)
            .MoveTo(1, -1)
            .MoveTo(1, -1)
            .Release();

            IMultiAction m = new MultiAction(driver);

            m.Add(a1).Add(a2).Add(smile);
            m.Perform();
            Thread.Sleep(10000);
            driver.Navigate().Back();
            Thread.Sleep(1000);
            driver.Navigate().Back();
            Thread.Sleep(1000);
            driver.GetScreenshot();
        }