Automation API

Android device automation

Helper Utilities

Utils

Random gesture helpers and server connectivity

Access these methods through agent.utils. Utility methods for human-like interactions and server checks.

randomClick()

TypeScript
randomClick(x1: number, y1: number, x2: number, y2: number): void

Performs a tap at a random position within the specified rectangle. Useful for making automations appear more human-like.

Parameters

NameTypeDescription
x1numberLeft boundary
y1numberTop boundary
x2numberRight boundary
y2numberBottom boundary

Examples

Using node.randomClick (preferred)
TypeScript
const button = screen.findTextOne("Submit");
if (button) {
button.randomClick();
}
Using agent.utils.randomClick (legacy)
TypeScript
const { left, top, right, bottom } = button.boundsInScreen;
agent.utils.randomClick(left, top, right, bottom);

randomSwipe()

TypeScript
randomSwipe(x1: number, y1: number, x2: number, y2: number, direction: "up" | "down" | "left" | "right"): void

Performs a swipe starting from a random position within the rectangle, moving in the specified direction.

Parameters

NameTypeDescription
x1numberLeft boundary
y1numberTop boundary
x2numberRight boundary
y2numberBottom boundary
direction"up" | "down" | "left" | "right"Swipe direction

Examples

Using node.randomSwipe (preferred)
TypeScript
const scrollView = screen.findAdvanced(f => f.isScrollable());
if (scrollView) {
scrollView.randomSwipe("up");
}
Using agent.utils.randomSwipe (legacy)
TypeScript
agent.utils.randomSwipe(100, 500, 900, 1500, "up");

isServerReachable()

TypeScript
isServerReachable(): Promise<{ reachable: true } | { reachable: false; error: string }>

Checks if the server is reachable. Useful for verifying connectivity before performing server-dependent operations.

Returns

{ reachable: true } | { reachable: false; error: string }Object indicating server reachability status

Examples

TypeScript
const status = await agent.utils.isServerReachable();
if (status.reachable) {
console.log("Server is reachable");
// Proceed with server operations
} else {
console.log("Server unreachable:", status.error);
// Handle offline scenario
}