Automation API

Android device automation

AgentConstants

Interface

Accessibility action constants for use with performAction()

These constants represent Android accessibility actions that can be performed on UI nodes. Use them with the node.performAction() method.

Usage Example
TypeScript
// Click a node using accessibility action
const screen = await agent.actions.screenContent();
const button = screen.findTextOne("Submit");
if (button) {
await button.performAction(agent.constants.ACTION_CLICK);
}
// Set text on an input field
const input = screen.findAdvanced(f => f.isEditText());
if (input) {
await input.performAction(
agent.constants.ACTION_SET_TEXT,
{ [agent.constants.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE]: "Hello World" }
);
}

Action Constants

Basic Actions

ConstantValueDescription
ACTION_FOCUS1Set focus on the node
ACTION_CLEAR_FOCUS2Clear focus from the node
ACTION_SELECT4Select the node
ACTION_CLEAR_SELECTION8Clear selection from the node
ACTION_CLICK16Perform a click action on the node
ACTION_LONG_CLICK32Perform a long click action on the node
ACTION_ACCESSIBILITY_FOCUS64Set accessibility focus
ACTION_CLEAR_ACCESSIBILITY_FOCUS128Clear accessibility focus

Navigation Actions

ConstantValueDescription
ACTION_NEXT_AT_MOVEMENT_GRANULARITY256Move to next element at given granularity
ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY512Move to previous element at given granularity
ACTION_NEXT_HTML_ELEMENT1024Navigate to next HTML element
ACTION_PREVIOUS_HTML_ELEMENT2048Navigate to previous HTML element

Scroll Actions

ConstantValueDescription
ACTION_SCROLL_FORWARD4096Scroll forward (down or right)
ACTION_SCROLL_BACKWARD8192Scroll backward (up or left)
ACTION_SCROLL_UP16908344Scroll up
ACTION_SCROLL_DOWN16908346Scroll down
ACTION_SCROLL_LEFT16908345Scroll left
ACTION_SCROLL_RIGHT16908347Scroll right
ACTION_SCROLL_TO_POSITION16908343Scroll to a specific position
ACTION_SCROLL_IN_DIRECTION1000072Scroll in a specific direction
ACTION_PAGE_UP16908358Page up
ACTION_PAGE_DOWN16908359Page down
ACTION_PAGE_LEFT16908360Page left
ACTION_PAGE_RIGHT16908361Page right

Editing Actions

ConstantValueDescription
ACTION_CUT65536Cut text to clipboard
ACTION_COPY16384Copy text to clipboard
ACTION_PASTE32768Paste text from clipboard
ACTION_SET_SELECTION131072Set text selection range
ACTION_SET_TEXT2097152Set the text content

Expand/Collapse Actions

ConstantValueDescription
ACTION_EXPAND262144Expand a collapsible node
ACTION_COLLAPSE524288Collapse an expanded node
ACTION_DISMISS1048576Dismiss/close a dismissable node

Advanced Actions

ConstantValueDescription
ACTION_SHOW_ON_SCREEN16908342Scroll to make the node visible
ACTION_SET_PROGRESS16908349Set progress value (e.g., SeekBar)
ACTION_CONTEXT_CLICK16908348Perform context click (right-click)
ACTION_SHOW_TOOLTIP16908356Show tooltip
ACTION_HIDE_TOOLTIP16908357Hide tooltip
ACTION_PRESS_AND_HOLD16908362Press and hold the node
ACTION_IME_ENTER16908372Submit via IME enter key
ACTION_SHOW_TEXT_SUGGESTIONS16908376Show text suggestions
ACTION_MOVE_WINDOW16908354Move a window

Drag Actions

ConstantValueDescription
ACTION_DRAG_START16908373Start a drag operation
ACTION_DRAG_DROP16908374Drop at current position
ACTION_DRAG_CANCEL1690837Cancel the drag operation

Argument Constants

These constants are used as keys in the data parameter of performAction() to pass additional arguments.

ConstantValueDescription
ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT"ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT"Movement granularity for navigation
ACTION_ARGUMENT_HTML_ELEMENT_STRING"ACTION_ARGUMENT_HTML_ELEMENT_STRING"HTML element type for navigation
ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN"ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN"Whether to extend selection
ACTION_ARGUMENT_SELECTION_START_INT"ACTION_ARGUMENT_SELECTION_START_INT"Selection start position
ACTION_ARGUMENT_SELECTION_END_INT"ACTION_ARGUMENT_SELECTION_END_INT"Selection end position
ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE"ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE"Text to set
ACTION_ARGUMENT_MOVE_WINDOW_X"ACTION_ARGUMENT_MOVE_WINDOW_X"Window X position
ACTION_ARGUMENT_MOVE_WINDOW_Y"ACTION_ARGUMENT_MOVE_WINDOW_Y"Window Y position
ACTION_ARGUMENT_ACCESSIBLE_CLICKABLE_SPAN"android.view.accessibility.action.ACTION_ARGUMENT_ACCESSIBLE_CLICKABLE_SPAN"Clickable span reference
ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT"android.view.accessibility.action.ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT"Press and hold duration in ms
ARGUMENT_DIRECTION_INT"android.view.accessibility.action.ARGUMENT_DIRECTION_INT"Direction for scroll operations
ARGUMENT_SCROLL_AMOUNT_FLOAT"android.view.accessibility.action.ARGUMENT_SCROLL_AMOUNT_FLOAT"Scroll amount/distance