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>

Performs a single tap at the specified screen coordinates.

Parameters

NameTypeDescription
xnumberX coordinate on screen
ynumberY coordinate on screen

Returns

Promise<void>Resolves when tap is complete

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(x1: number, y1: number, x2: number, y2: number, duration: number): Promise<void>

Performs a swipe gesture from one point to another.

Parameters

NameTypeDescription
x1numberStarting X coordinate
y1numberStarting Y coordinate
x2numberEnding X coordinate
y2numberEnding Y coordinate
durationnumberDuration in milliseconds

Returns

Promise<void>Resolves when swipe is complete

Examples

Swipe up
TypeScript
await agent.actions.swipe(500, 1500, 500, 500, 300);
Swipe right
TypeScript
await agent.actions.swipe(100, 500, 900, 500, 200);

hold()

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

Performs a long press at the specified coordinates.

Parameters

NameTypeDescription
xnumberX coordinate
ynumberY coordinate
durationnumberHold duration in milliseconds

Returns

Promise<void>Resolves when hold is complete

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, bezier?: boolean): Promise<void>

Performs a multi-point swipe through a sequence of coordinates.

Parameters

NameTypeDescription
startXnumberStarting X coordinate
startYnumberStarting Y coordinate
sequence{x: number, y: number}[]Array of points to swipe through
durationnumberTotal duration in milliseconds
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);