Automation API

Android device automation

ADB Actions

Actions

ADB shell-based device actions that bypass the accessibility service

Access these methods through agent.actions.adb. These actions use ADB shell commands instead of the accessibility service, providing an alternative when the accessibility service is unavailable or unreliable.

Available since: App version 2.141 (153)

tap()

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

Performs a single tap at the specified screen coordinates using ADB shell input.

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.adb.tap(100, 200);

hold()

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

Performs a long press at the specified coordinates using ADB shell input.

Parameters

NameTypeDescription
xnumberX coordinate on screen
ynumberY coordinate on screen
durationnumberHold duration in milliseconds

Returns

Promise<void>Resolves when hold is complete

Examples

Long press for 1 second
TypeScript
await agent.actions.adb.hold(500, 500, 1000);

swipe()

TypeScript
swipe(x1: number, y1: number, x2: number, y2: number, duration: number): Promise<void>

Performs a swipe gesture from one point to another using ADB shell input.

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.adb.swipe(500, 1500, 500, 500, 300);

swipePoly()

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

Swipes through multiple points sequentially using ADB shell input. Each segment is executed as a separate ADB swipe command. Optionally supports per-segment duration.

Parameters

NameTypeDescription
startXnumberStarting X coordinate
startYnumberStarting Y coordinate
sequence{x, y, duration?}[]Array of points to swipe through. Each point can optionally specify its own duration in ms.
durationnumberTotal duration in ms. Divided equally among segments if per-point durations are not specified. Use 0 for default (~500ms total).

Returns

Promise<void>Resolves when all swipe segments are complete

Examples

Draw an L shape
TypeScript
await agent.actions.adb.swipePoly(100, 100, [
{ x: 100, y: 500 },
{ x: 400, y: 500 }
], 600);
With per-segment duration
TypeScript
await agent.actions.adb.swipePoly(100, 100, [
{ x: 100, y: 500, duration: 200 },
{ x: 400, y: 500, duration: 300 }
], 0);

doubleTap()

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

Performs a double tap at the specified coordinates using ADB shell input.

Parameters

NameTypeDescription
xnumberX coordinate on screen
ynumberY coordinate on screen
interval?numberInterval between taps in ms (default: 100)

Returns

Promise<void>Resolves when double tap is complete

Examples

Double tap
TypeScript
await agent.actions.adb.doubleTap(500, 500);
Double tap with custom interval
TypeScript
await agent.actions.adb.doubleTap(500, 500, 200);

goHome()

TypeScript
goHome(): Promise<void>

Returns to the home screen using ADB keyevent.

Returns

Promise<void>Resolves when navigation is complete

Examples

TypeScript
await agent.actions.adb.goHome();

goBack()

TypeScript
goBack(): Promise<void>

Presses the system back button using ADB keyevent.

Returns

Promise<void>Resolves when back action is complete

Examples

TypeScript
await agent.actions.adb.goBack();

recents()

TypeScript
recents(): Promise<void>

Opens the recent apps screen using ADB keyevent.

Returns

Promise<void>Resolves when recent apps screen is shown

Examples

TypeScript
await agent.actions.adb.recents();

dpad()

TypeScript
dpad(direction: "up" | "down" | "left" | "right" | "center"): Promise<void>

Sends a D-pad navigation event using ADB keyevent.

Parameters

NameTypeDescription
direction"up" | "down" | "left" | "right" | "center"Direction to navigate

Returns

Promise<void>Resolves when navigation is complete

Examples

TypeScript
await agent.actions.adb.dpad("down");
TypeScript
await agent.actions.adb.dpad("center"); // Select/Enter

inputKey()

TypeScript
inputKey(keyCode: number, duration?: number): Promise<void>

Sends a key input event using ADB keyevent. Supports long press via duration parameter.

Parameters

NameTypeDescription
keyCodenumberAndroid KeyEvent code (e.g., 66 for Enter, 67 for Backspace)
duration?numberPress duration in ms. 0 for normal press, >0 for long press (default: 0)

Returns

Promise<void>Resolves when key event is complete

Examples

Press Enter
TypeScript
await agent.actions.adb.inputKey(66);
Long press a key
TypeScript
await agent.actions.adb.inputKey(66, 1000);

writeText()

TypeScript
writeText(text: string): Promise<void>

Types text using ADB shell input. Special characters are automatically escaped.

Parameters

NameTypeDescription
textstringText to type

Returns

Promise<void>Resolves when text is typed

Examples

TypeScript
await agent.actions.adb.writeText("Hello World");

launchApp()

TypeScript
launchApp(packageName: string): Promise<void>

Launches an app by its package name using ADB monkey command.

Parameters

NameTypeDescription
packageNamestringThe app's package name (e.g., com.android.chrome)

Returns

Promise<void>Resolves when app launch command is sent

Examples

TypeScript
await agent.actions.adb.launchApp("com.android.chrome");

screenContent()

TypeScript
screenContent(): Promise<AndroidNode>

Gets the current screen content (UI hierarchy) via ADB uiautomator dump. Returns the same AndroidNode structure as the regular screenContent() method.

Returns

Promise<AndroidNode>Root node of the accessibility tree

Examples

Get screen content via ADB
TypeScript
const screen = await agent.actions.adb.screenContent();
const button = screen.findTextOne("Submit");

listApps()

TypeScript
listApps(): Promise<string[]>

Gets the list of installed package names via ADB pm list packages.

Returns

Promise<string[]>Array of installed package names

Examples

List installed apps
TypeScript
const apps = await agent.actions.adb.listApps();
console.log(apps); // ["com.android.chrome", "com.google.android.youtube", ...]

screenshot()

TypeScript
screenshot(maxWidth: number, maxHeight: number, quality: number, cropX1?: number, cropY1?: number, cropX2?: number, cropY2?: number): Promise<{...}>

Takes a screenshot via ADB screencap. Returns the image as a base64-encoded JPEG string along with dimension metadata.

Parameters

NameTypeDescription
maxWidthnumberMaximum width to scale down to
maxHeightnumberMaximum height to scale down to
qualitynumberJPEG quality (1-100)
cropX1?numberCrop left coordinate
cropY1?numberCrop top coordinate
cropX2?numberCrop right coordinate
cropY2?numberCrop bottom coordinate

Returns

Promise<{ screenshot, compressedWidth, compressedHeight, originalWidth, originalHeight }>Screenshot data with base64 image and dimensions

Examples

Take a screenshot via ADB
TypeScript
const result = await agent.actions.adb.screenshot(720, 1280, 80);
console.log(result.originalWidth, result.originalHeight);
Take a cropped screenshot
TypeScript
const result = await agent.actions.adb.screenshot(720, 1280, 80, 0, 0, 360, 640);

allScreensContent()

TypeScript
allScreensContent(): Promise<AndroidNode[]>

Gets the UI hierarchy from all screens/windows via ADB. Returns an array of AndroidNode objects, one per window.

Returns

Promise<AndroidNode[]>Array of root nodes, one per screen/window

Examples

Get all screens content via ADB
TypeScript
const screens = await agent.actions.adb.allScreensContent();
for (const screen of screens) {
const buttons = screen.findText("OK");
console.log(buttons.length);
}