Automation API

Android device automation

Agent

Interface

The main entry point for all automation functionality

The agent object is globally available in all automation scripts. It provides access to device controls, screen content, file operations, and more through its namespaced properties.

Agent Interface
TypeScript
interface Agent {
/** Accessibility action constants */
constants: AgentConstants;
/** All automation actions */
actions: AgentActions;
/** Utility functions */
utils: AgentUtils;
/** Device and automation info */
info: AgentInfo;
/** Automation control */
control: AgentControl;
/** HTML overlay display */
display: AgentDisplay;
/** Email operations */
email: AgentEmail;
/** Notification handling */
notifications: AgentNotifications;
/** Record usage statistics */
recordUsage(type: string, usage: number): void;
}

Namespaces

Quick Example

TypeScript
// Tap at coordinates
await agent.actions.tap(100, 200);
// Get screen content and find elements
const screen = await agent.actions.screenContent();
const button = screen.findTextOne("Submit");
// Perform action on a node
if (button) {
await button.performAction(agent.constants.ACTION_CLICK);
}
// Get device info
const device = agent.info.getDeviceInfo();
console.log(device.brand, device.model);
// Read a file
const content = agent.utils.files.readFullFile("/sdcard/data.txt");