public virtual void ScrollTo(string automationId) { var action = new TouchActions(Driver); action.Scroll(0, 100) .Perform(); }
public void tapElement(AppiumWebElement element) { TouchActions actions = new TouchActions(driver); actions.SingleTap(element); actions.Perform(); }
/// <summary> /// Gets the list of actions for the touch action to be used in MultiTouchAction /// </summary> /// <param name="touchAction">touch action</param> /// <returns></returns> public static List <Dictionary <string, object> > GetActionsList(this TouchActions touchAction) { if (null == touchAction) { throw new ArgumentNullException("touchAction"); } var actionsList = new List <Dictionary <string, object> >(); foreach (var iaction in touchAction.GetActions()) { Dictionary <string, object> yy = null; if (null == iaction) { // do nothing } else if (null == (yy = iaction._GetParameters())) { // do nothing } else { actionsList.Add(yy); } } return(actionsList); }
/// <summary> /// Performs a long tap on the element of the specified driver. /// </summary> /// <param name="driver">The driver to use.</param> /// <param name="element">The element to long tap.</param> public static void Longtap(IWebDriver driver, IWebElement element) { if (driver is IHasTouchScreen) { TouchActions longtap = new TouchActions(driver); Point center = GetCenter(element); longtap.Down(center.X, center.Y); longtap.Perform(); try { Thread.Sleep(750); } catch (ThreadInterruptedException) { } longtap.Up(center.X, center.Y); longtap.Perform(); } else { ILocatable locatable = (ILocatable)element; ICoordinates coords = locatable.Coordinates; IMouse mouse = ((IHasInputDevices)driver).Mouse; mouse.MouseDown(coords); try { Thread.Sleep(750); } catch (ThreadInterruptedException) { } mouse.MouseUp(coords); } }
protected void DoubleTap(IWebElement element) { WaitForElement(element); TouchActions action = new TouchActions(DriverFactory.INSTANCE); action.DoubleTap(element); action.Perform(); }
protected void doubleTap(IWebElement element) { WaitForElement(element); //IWebElement iElement = driver.FindElement(element); TouchActions action = new TouchActions(DriverFactory.GetDriver()); action.DoubleTap(element); action.Perform(); }
protected void LongPress(IWebElement element) { WaitForElement(element); TouchActions action = new TouchActions(DriverFactory.INSTANCE); action.LongPress(element); action.Release(); action.Perform(); }
protected void longPress(IWebElement element) { WaitForElement(element); //IWebElement iElement = driver.FindElement(element); TouchActions action = new TouchActions(DriverFactory.GetDriver()); action.LongPress(element); action.Perform(); }
/// <summary> /// Add touch actions to be performed /// </summary> /// <param name="touchAction"></param> public MultiTouchAction Add(TouchActions touchAction) { if (null == touchAction) { throw new ArgumentNullException("touchAction"); } _MultiTouchActionList.Add(touchAction); return(this); }
/// <summary> /// Performs a single tap on the element of the specified driver. /// </summary> /// <param name="driver">The driver to use.</param> /// <param name="element">The element.</param> public static void Tap(IWebDriver driver, IWebElement element) { if (driver is IHasTouchScreen) { TouchActions tap = (new TouchActions(driver)).SingleTap(element); tap.Perform(); } else { element.Click(); } }
protected void Tap(IWebElement element) { //waitForElement(element); //TouchActions action = new TouchActions(driver); //action.singleTap(element); //action.perform(); WaitForElement(element); //IWebElement iElement = driver.FindElement(element); TouchActions action = new TouchActions(DriverFactory.GetDriver()); action.SingleTap(element); action.Perform(); }
public void TouchUp() { if (!_interactionEnabled) { return; } if (!_touchedDown) { return; } _touchedDown = false; TouchActions.TouchUp(Input.mousePosition); }
public void TestTouchActions() { var touches = new TouchActions(this.driver); var pivot = this.driver.FindElementById("MainPivot"); touches.Flick(pivot, -300, 0, 500).Perform(); var wait = new WebDriverWait(this.driver, TimeSpan.FromSeconds(5)); var element = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("SecondTabTextBox"))); Assert.AreEqual("Nice swipe!", element.Text); }
public void TouchDown() { if (!_interactionEnabled) { return; } if (touchCount == 0) { touchCount++; StartCoroutine(StartLevelWithDelay()); } _touchedDown = true; TouchActions.TouchDown(Input.mousePosition); }
public void TouchEvent_CanTrigger() { Browser.MountTestComponent <TouchEventComponent>(); var input = Browser.Exists(By.Id("touch_input")); var output = Browser.Exists(By.Id("output")); Assert.Equal(string.Empty, output.Text); var actions = new TouchActions(Browser).SingleTap(input); actions.Perform(); Browser.Equal("touchstart,touchend,", () => output.Text); }
public IReturnType Calculate(Objects.ValidSetOfTouchPoints set) { TouchActions actions = new TouchActions(); foreach (var item in set) { TouchActionInfo info = new TouchActionInfo() { Action = item.Action, TouchDeviceId = item.TouchDeviceId }; actions.Add(info); } return actions; }
/// <summary> /// Zoom at the specified point /// </summary> /// <param name="x">x screen location</param> /// <param name="y">y screen location</param> public void Zoom(int x, int y) { var touchAction1 = new TouchActions(this); touchAction1.Down(x, y).Move(x, y - 100).Up(x, y - 100); var touchAction2 = new TouchActions(this); touchAction2.Down(x, y).Move(x, y + 100).Up(x, y + 100); var multiTouchAction = new MultiTouchAction(this); multiTouchAction.Add(touchAction1); multiTouchAction.Add(touchAction2); PerformMultiTouchAction(multiTouchAction); }
/// <summary> /// Pause execution of action chain for the given number of milliseconds. /// Defaults to zero so that it can be used for synchronizing actions /// </summary> /// <param name="touchAction">touch action chain to pause</param> /// <param name="ms">number of milliseconds to pause the action chain for</param> /// <returns></returns> public static TouchActions Wait(this TouchActions touchAction, int ms = 0) { if (null == touchAction) { throw new ArgumentNullException("touchAction"); } // use reflection to find the AddAction() to add the wait action into the action chain var mi = typeof(TouchActions).GetMethod("AddAction", BindingFlags.NonPublic | BindingFlags.Instance); if (null != mi) { mi.Invoke(touchAction, new object[] { new WaitAction(ms) }); } return(touchAction); }
public void DraggableItemsTest() { IWebElement DraggableItem = _driver.FindElement(By.XPath("//div[@id='todrag']/span")); IWebElement DropBox = _driver.FindElement(By.Id("mydropzone")); TouchActions drag = new TouchActions(_driver); drag.LongPress(DraggableItem) .MoveToElement(DropBox) .Release(DropBox) .Perform(); System.Threading.Thread.Sleep(15000); _driver.FindElement(DroppedItemList).Text.Should().Contain("Draggable 1"); }
public void ShouldTouch() { //Dictionary<String, String> mobileEmulation = new Dictionary<String, String>(); //mobileEmulation.Add("deviceName", "Nexus 5"); ChromeOptions chromeCapabilities = new ChromeOptions(); chromeCapabilities.EnableMobileEmulation("Google Nexus 5"); var driver = new TouchCapableChromeDriver(); driver.Navigate().GoToUrl("https://en.wikipedia.org/wiki/Main_Page"); var element = driver.FindElement(By.Id("searchInput")); var touchActions = new TouchActions(driver); touchActions.SingleTap(element) .Perform(); driver.Quit(); }
/// <summary> /// Returns a list of actions /// </summary> /// <param name="actions"></param> /// <returns></returns> private static IEnumerable <IAction> GetActions(this TouchActions actions) { List <IAction> retVal = null; if (null == actions) { return(null); } try { //var compositeActionObj = _ActionFieldInfo.Value.GetValue(actions); retVal = _ActionsListFieldInfo.Value.GetValue(actions.Build()) as List <IAction>; } catch { // unable to get the field } return(retVal); }
public void scrollDown() { TouchActions actions = new TouchActions(driver); actions.Scroll(50, 0); }
/// <summary> /// Tracks the element of the specified driver by the specified offsets /// </summary> /// <param name="driver">The driver to use.</param> /// <param name="element">The element to track.</param> /// <param name="x">Amount of pixels to move horizontally</param> /// <param name="y">Amount of pixels to move vertically</param> /// <param name="step">Generate a move event every (step) pixels</param> public static void Track(IWebDriver driver, IWebElement element, int x, int y, int step) { if (driver is IHasTouchScreen) { if (step == 0) { step = 1; // TODO: no move if step == 0 } Point center = GetCenter(element); int posX = center.X; int posY = center.Y; int endX = posX + x; int endY = posY + y; TouchActions touchAction = new TouchActions(driver); touchAction.Down(posX, posY); while ((x < 0 && posX > endX || x > 0 && posX < endX) || (y < 0 && posY > endY || y > 0 && posY < endY)) { if (x > 0 && posX < endX) { if (posX + step > endX) { posX += endX - (posX + step); } else { posX += step; } } else if (x < 0 && posX > endX) { if (posX - step < endX) { posX -= endX + (posX - step); } else { posX -= step; } } if (y > 0 && posY < endY) { if (posY + step > endY) { posY += endY - (posY + step); } else { posY += step; } } else if (y < 0 && posY > endY) { if (posY - step < endY) { posY -= endY + (posY - step); } else { posY -= step; } } touchAction.Move(posX, posY); } touchAction.Up(posX, posY).Perform(); } else { Actions mouseAction = new Actions(driver); mouseAction.DragAndDropToOffset(element, x, y); } }
public TouchService(IWebDriver wrappedDriver) : base(wrappedDriver) { WrappedTouchActions = new TouchActions(wrappedDriver); }