Helper Utilities
UtilsRandom 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): voidPerforms a tap at a random position within the specified rectangle. Useful for making automations appear more human-like.
Parameters
| Name | Type | Description |
|---|---|---|
x1 | number | Left boundary |
y1 | number | Top boundary |
x2 | number | Right boundary |
y2 | number | Bottom 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"): voidPerforms a swipe starting from a random position within the rectangle, moving in the specified direction.
Parameters
| Name | Type | Description |
|---|---|---|
x1 | number | Left boundary |
y1 | number | Top boundary |
x2 | number | Right boundary |
y2 | number | Bottom 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}