Appium Interactions Cheat Sheet

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).
tap(PointOption.point(200, 300)).perform()

Long Press

Press and hold on an element or coordinates.

new TouchAction(driver).
longPress(PointOption.point(100, 200)).release().perform()

Press & Release

Simulates quick press and release.

new TouchAction(driver).
press(PointOption.point(150, 250)).release().perform()

Swipe

Drags from one point to another.

new TouchAction(driver).press(PointOption.point(100, 500)).
waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1))).
moveTo(PointOption.point(100, 100)).release().perform()

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.
AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(\"Login\"))"))

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)).
moveTo(ElementOption.element(target)).release().perform()

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()

 

Related Tutorials