예제 #1
0
        public void LongPressTestCase()
        {
            RequestProcessor re = setupTouchAction ();
            IWebElement element = driver.FindElementByIosUIAutomation (".elements()");

            ITouchAction a;

            a = new TouchAction (driver)
                .LongPress (element, 50, 75);
            a.Perform ();
            Assert.AreEqual (re.inputData, "{\"actions\":[{\"action\":\"longpress\",\"options\":{\"element\":\"5\",\"x\":50,\"y\":75}}]}");

            a = new TouchAction (driver)
                .LongPress (element, 0.5, 75);
            a.Perform ();
            Assert.AreEqual (re.inputData, "{\"actions\":[{\"action\":\"longpress\",\"options\":{\"element\":\"5\",\"x\":0.5,\"y\":75}}]}");

            a = new TouchAction (driver)
                .LongPress (0.5, 75);
            a.Perform ();
            Assert.AreEqual (re.inputData, "{\"actions\":[{\"action\":\"longpress\",\"options\":{\"x\":0.5,\"y\":75}}]}");

            a = new TouchAction (driver)
                .LongPress (element);
            a.Perform ();
            Assert.AreEqual (re.inputData, "{\"actions\":[{\"action\":\"longpress\",\"options\":{\"element\":\"5\"}}]}");
        }
예제 #2
0
        public void MoveToTestCase()
        {
            IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities);
            RequestProcessor re = setupTouchAction();
            IWebElement element = driver.FindElementByIosUIAutomation(".elements()");

            ITouchAction a;

            a = new TouchAction(driver)
                .MoveTo(element, 50, 75);
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"element\":\"5\",\"x\":50,\"y\":75}}]}");

            a = new TouchAction(driver)
                .MoveTo(element, 0.5, 75);
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"element\":\"5\",\"x\":0.5,\"y\":75}}]}");

            a = new TouchAction(driver)
                .MoveTo(0.5, 75);
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"x\":0.5,\"y\":75}}]}");

            a = new TouchAction(driver)
                .MoveTo(element);
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"element\":\"5\"}}]}");
        }
		public void SimpleActionTestCase ()
		{
			IWebElement el = driver.FindElementByAccessibilityId ("ComputeSumButton");
			ITouchAction action = new TouchAction(driver);
			action.Press(el, 10, 10).Release();
			action.Perform ();
		}
예제 #4
0
		public static ITouchAction Swipe(IPerformsTouchActions driver, int startX, int startY, int endX, int endY, 
				int duration) {
			ITouchAction touchAction = new TouchAction(driver) 
				.Press (startX, startY)
				.Wait (duration)
				.MoveTo (endX, endY)
				.Release ();
			return touchAction;
		}
		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 ();
		}
        public void CheckTap(IPerformsTouchActions performer)
        {
            TouchAction t = new TouchAction(performer);
            t.Tap(accessibility);
            t.Perform();

            MultiAction m = new MultiAction(performer);
            m.Add(new TouchAction(performer).Tap(customView));
            m.Add(new TouchAction(performer).Tap(clickable));
            m.Perform();
        }
예제 #7
0
 public void SimpleActionTestCase()
 {
     driver.FindElementById ("TextField1").Clear();
     driver.FindElementById ("TextField1").SendKeys ("1");
     driver.FindElementById ("TextField2").Clear ();
     driver.FindElementById ("TextField2").SendKeys ("3");
     IWebElement el = driver.FindElementByAccessibilityId("ComputeSumButton");
     ITouchAction action = new TouchAction(driver);
     action.Press(el, 10, 10).Release();
     action.Perform();
     const string str = "4";
     Assert.AreEqual (driver.FindElementByXPath ("//*[@name = \"Answer\"]").Text, str);
 }
예제 #8
0
        public void SimpleTouchActionTestCase()
        {
            IList<AppiumWebElement> els = driver.FindElementsByClassName("android.widget.TextView");

            int number1 = els.Count;

            TouchAction tap = new TouchAction(driver);
            tap.Tap(els[4], 10, 5, 2).Perform();

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

            Assert.AreNotEqual(number1, els.Count);
        }
예제 #9
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);
 }
        public void AppiumDriverPressMethod()
        {

            var elements = _driver.FindElementsByAndroidUIAutomator("new UiSelector().enabled(true)");
            var button = elements[11];

            TouchAction a1 = new TouchAction(_driver);
                a1
                  .Press(button)
                  .Wait(1000)
                  .Release();
                a1.Perform();

            elements = _driver.FindElementsByAndroidUIAutomator("new UiSelector().enabled(true)");
            var textV = elements[19];
            textV.SendKeys("495");

            Assert.AreEqual(textV.Text,495.ToString());
        }
예제 #11
0
        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);
        }
 private void performTouch(AndroidElement element)
 {
     if (element != null)
     {
         TouchAction a1 = new TouchAction(driver);
         a1
           .Press(element, 100, 100)
           .Wait(1000)
           .Release();
         a1.Perform();
     }
 }
예제 #13
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();
            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();
            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\"}}]]}");
        }
예제 #14
0
        /// <summary>
        /// Perform the touch action
        /// </summary>
        /// <param name="touchAction">touch action to perform</param>
        public void PerformTouchAction(TouchAction touchAction)
        {
            if (null == touchAction)
            {
                return; // do nothing
            }

            var parameters = new Dictionary<string, object>();
            parameters.Add("actions", touchAction.GetParameters());
            this.Execute(AppiumDriverCommand.TouchActionV2Perform, parameters);
        }
예제 #15
0
        public void WaitTestCase()
        {
            IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities);
            RequestProcessor re = setupTouchAction();
            ITouchAction a;

            a = new TouchAction(driver)
                .Wait(1000);
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"wait\",\"options\":{\"ms\":1000}}]}");

            a = new TouchAction(driver)
                .Wait();
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"wait\"}]}");
        }
예제 #16
0
        public void ReleaseTestCase()
        {
            IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities);
            RequestProcessor re = setupTouchAction();
            ITouchAction a;

            a = new TouchAction(driver)
                .Release();
            a.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"release\"}]}");
        }
예제 #17
0
		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();
		}
예제 #18
0
        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);
        }
예제 #19
0
        public void ReleaseTestCase()
        {
            RequestProcessor re = setupTouchAction ();
            ITouchAction a;

            a = new TouchAction (driver)
                .Release ();
            a.Perform ();
            Assert.AreEqual (re.inputData, "{\"actions\":[{\"action\":\"release\"}]}");
        }
예제 #20
0
        public void WaitTestCase()
        {
            RequestProcessor re = setupTouchAction ();
            ITouchAction a;

            a = new TouchAction (driver)
                .Wait (1000);
            a.Perform ();
            Assert.AreEqual (re.inputData, "{\"actions\":[{\"action\":\"wait\",\"options\":{\"ms\":1000}}]}");

            a = new TouchAction (driver)
                .Wait ();
            a.Perform ();
            Assert.AreEqual (re.inputData, "{\"actions\":[{\"action\":\"wait\"}]}");
        }