From taps and swipes to advanced multi-touch gestures, Appium offers a wide range of interaction commands to simulate real user behavior on mobile apps. This cheat sheet lists the most commonly used gesture and pointer commands.
|
Command / Action |
Description |
Example / Notes |
|
Tap (TouchAction) |
Single tap at specific coordinates or element. |
new TouchAction(driver). |
|
Long Press |
Press and hold on an element or coordinates. |
new TouchAction(driver). |
|
Press & Release |
Simulates quick press and release. |
new TouchAction(driver). |
|
Swipe |
Drags from one point to another. |
new TouchAction(driver).press(PointOption.point(100, 500)). |
|
Scroll (mobile: scroll) |
Scrolls until element is visible (iOS). |
driver.executeScript("mobile: scroll", Map.of("direction", "down")) |
|
Scroll (Android UiScrollable) |
Scrolls to find element (Android). |
driver.findElement(MobileBy. |
|
Pinch |
Zooms out gesture. |
driver.executeScript("mobile: pinch", params) |
|
Zoom |
Zooms in gesture. |
driver.executeScript("mobile: doubleTap", params) |
|
Double Tap |
Double tap on element or coordinates. |
driver.executeScript("mobile: doubleTap", params) |
|
Drag and Drop |
Drags an element to new location. |
new TouchAction(driver).longPress(ElementOption.element(source)). |
|
Multi-touch Action |
Combines multiple touch actions at once. |
new MultiTouchAction(driver).add(touch1).add(touch2).perform() |
|
Pointer Input (W3C) |
Low-level gesture using pointer actions (touch/mouse). |
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger") |
|
Mouse Move |
Moves mouse pointer to coordinates (desktop context). |
actions.moveByOffset(50, 100).perform() |
|
Mouse Click |
Single mouse click. |
actions.click().perform() |
|
Mouse Double Click |
Double mouse click. |
actions.doubleClick().perform() |
|
Mouse Right Click |
Right click (context click). |
actions.contextClick().perform() |
|
Mouse Drag and Drop |
Mouse-based drag and drop. |
actions.dragAndDrop(source, target).perform() |