Skip to content

Automation API

Android device automation

Touch Actions

Actions

Touch gestures for device interaction

Access these methods through agent.actions. All touch methods are asynchronous and return Promises.

tap()

TypeScript
tap(x: number, y: number): Promise<void>

Taps the screen at the given device-pixel coordinates.

Parameters

NameTypeDescription
xnumberX coordinate in device pixels.
ynumberY coordinate in device pixels.

Returns

Promise<void>Resolves once the tap is dispatched.

Examples

Simple tap
TypeScript
await agent.actions.tap(100, 200);
Tap center of a node
TypeScript
const node = screen.findTextOne("Submit");
if (node) {
const { left, top, right, bottom } = node.boundsInScreen;
await agent.actions.tap((left + right) / 2, (top + bottom) / 2);
}

swipe()

TypeScript
swipe(from: Point, to: Point, ms?: number): Promise<void>

Swipes between two points over the given duration.

Parameters

NameTypeDescription
fromPointStart point { x, y }.
toPointEnd point { x, y }.
ms?numberSwipe duration. (default: 400)

Returns

Promise<void>Resolves once the swipe completes.

Examples

Swipe up
TypeScript
await agent.actions.swipe({ x: 500, y: 1500 }, { x: 500, y: 500 }, 300);
Swipe right
TypeScript
await agent.actions.swipe({ x: 100, y: 500 }, { x: 900, y: 500 }, 200);

hold()

TypeScript
hold(x: number, y: number, ms?: number): Promise<void>

Long-presses at the coordinates for the given duration.

Parameters

NameTypeDescription
xnumberX coordinate.
ynumberY coordinate.
ms?numberHold duration. (default: 600)

Returns

Promise<void>Resolves once released.

Examples

TypeScript
await agent.actions.hold(500, 500, 1000); // Hold for 1 second

doubleTap()

TypeScript
doubleTap(x: number, y: number, interval: number): Promise<void>

Performs a double tap at the specified coordinates.

Parameters

NameTypeDescription
xnumberX coordinate
ynumberY coordinate
intervalnumberInterval between taps in milliseconds

Returns

Promise<void>Resolves when double tap is complete

Examples

TypeScript
await agent.actions.doubleTap(500, 500, 100);

multiTap()

TypeScript
multiTap(sequence: MultiTapSequenceItem[]): Promise<void>

Performs multiple taps in sequence with configurable delays.

Parameters

NameTypeDescription
sequenceMultiTapSequenceItem[]Array of {x, y, delay} objects where delay is ms to wait after each tap

Returns

Promise<void>Resolves when all taps are complete

Examples

TypeScript
await agent.actions.multiTap([
{ x: 100, y: 200, delay: 100 },
{ x: 300, y: 400, delay: 100 },
{ x: 500, y: 600, delay: 0 }
]);

swipePoly()

TypeScript
swipePoly(startX: number, startY: number, sequence: {x: number, y: number, duration?: number}[], duration: number, bezier?: boolean): Promise<void>

Performs a multi-point swipe through a sequence of coordinates. Each point can optionally specify its own segment duration for fine-grained timing control.

Parameters

NameTypeDescription
startXnumberStarting X coordinate
startYnumberStarting Y coordinate
sequence{x, y, duration?}[]Array of points to swipe through. Each point can optionally include a duration (ms) for that segment.
durationnumberTotal duration in milliseconds. Divided equally among segments if per-point durations are not specified.
bezier?booleanUse bezier curve interpolation

Returns

Promise<void>Resolves when swipe is complete

Examples

TypeScript
// Draw a zigzag pattern
await agent.actions.swipePoly(100, 500, [
{ x: 300, y: 400 },
{ x: 500, y: 600 },
{ x: 700, y: 400 }
], 500);
With per-segment duration
TypeScript
// Slow first segment, fast second
await agent.actions.swipePoly(100, 100, [
{ x: 100, y: 500, duration: 400 },
{ x: 400, y: 500, duration: 100 }
], 0);