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 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(); }
/// <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(); }
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(); }
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(); }
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 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 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 static void PinchToZoom(this AppiumDriver driver, Direction direction, double scale = 1.0) { EnsureScaleRange(scale); EnsureInOutDirection(direction); var windowSize = driver.ScreenSize(); var windowCenter = new Point(windowSize.Width / 2, windowSize.Height / 2); var upperLeft = new Point(windowCenter.X - windowSize.Width / 4, windowCenter.Y - windowSize.Height / 4); var bottomRight = new Point(windowCenter.X + windowSize.Width / 4, windowCenter.Y + windowSize.Height / 4); int deltaX, deltaY; switch (direction) { case Direction.In: deltaX = (int)(-1 * scale * upperLeft.X); deltaY = (int)(-1 * scale * upperLeft.Y); break; case Direction.Out: deltaX = (int)(scale * windowCenter.X - upperLeft.X); deltaY = (int)(scale * bottomRight.Y - windowCenter.Y); break; default: throw new InvalidEnumArgumentException("Invalid direction: " + direction); } var finger1 = new TouchAction(driver) .Press(upperLeft.X, upperLeft.Y) .Wait(1000) .MoveTo(deltaX, deltaY) .Wait(1000) .Release(); var finger2 = new TouchAction(driver) .Press(bottomRight.X, bottomRight.Y) .Wait(1000) .MoveTo((-1) * deltaX, (-1) * deltaY) .Wait(1000) .Release(); var zoomAction = new MultiAction(driver).Add(finger1).Add(finger2); zoomAction.Perform(); }
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); }
/// <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(); }