Skip to main content

Overview

Node operations allow you to find and interact with UI elements (nodes) in the accessibility tree. These methods provide various search strategies to locate elements by content description, view ID, text, class name, and more.

Finding and Clicking Elements

Click by Content Description

Find and click an element by its content description (accessibility label).
String
required
The content description text to search for (case-insensitive, partial match)
Example:
This method searches recursively through the entire UI tree and clicks the first clickable element whose content description contains the specified text.

Click by View ID

Click element(s) by their Android resource ID.
String
required
The full resource ID (e.g., “com.example.app:id/button_submit”)
Boolean
true if at least one element was clicked, false otherwise
Example:
By default, this method clicks up to the first 3 elements with the specified view ID, with 120ms delay between clicks. This prevents duplicate clicks on the same element.

Advanced View ID Methods

Click Multiple View IDs (Fallback)
Tries multiple view IDs until one succeeds:
Click All Elements with View ID
Clicks every element with the specified view ID (returns count of clicked elements).

Click by Text Label

Find and click an element by its exact text content.
String
required
The exact text label to search for (case-sensitive)
Example:

Click by Content Description (Collection)

Click the first element with an exact content description match.
String
required
The exact content description to match
Example:

Advanced Node Finding

Find by Class Name and Index

Find a node by its class name and position in the tree.
String
required
The fully qualified class name (e.g., “android.widget.Button”)
Int
required
Zero-based index of the element (in pre-order traversal)
AccessibilityNodeInfo?
The found node, or null if not found
Example:

Find by Class, Index, and String

Find a node matching class name, sibling index, and optional text content.
AccessibilityNodeInfo?
default:"rootInActiveWindow"
The root node to start searching from
String
required
The fully qualified class name to match
Int
required
The target index among siblings (relative position in parent). Use -1 to ignore index.
String?
required
Optional text/contentDescription that the node should contain. Use null to ignore.
AccessibilityNodeInfo?
The first matching node, or null if not found
Example:

Clicking Mechanisms

Perform Node Click

Attempt to click a node by traversing up to find a clickable parent.
AccessibilityNodeInfo
required
The node to click (or its nearest clickable parent)
Example:

Click at Approximate Coordinates

Click any clickable element near specific coordinates.
Float
required
The X coordinate in pixels
Float
required
The Y coordinate in pixels
Float
default:"50f"
Search radius in pixels
Boolean
true if a clickable element was found and clicked, false otherwise
Example:

Text Input Operations

Type in First Editable Field

Find the first editable text field and enter text.
String
required
The text to enter into the field
Example:
This method uses breadth-first search to find the first EditText that supports ACTION_SET_TEXT. The field is focused before text is entered.

Type in Second Editable Field

Find the second editable text field and enter text.
String
required
The text to enter into the second field
Example:

Type in Third Editable Field

Same as second field, but targets the third editable field in traversal order.

Type by Resource ID

Enter text into a field identified by its resource ID.
String
required
The full resource ID of the input field
String
required
The text to enter
Example:

Type by Class Name

Enter text into all fields matching a class name.
String
required
The class name to match (e.g., “android.widget.EditText”)
String
required
The text to enter into matching fields
Example:

Text Extraction

Get All Text from Screen

Extract all visible text from the current screen.
String
Concatenated text from all text nodes and content descriptions on screen
Example:

Check if Text is Present

Check if specific text exists anywhere on screen.
String
required
The text to search for (case-insensitive, partial match)
Boolean
true if the text is found in any node’s text or content description
Example:

Get Content Description

Get the content description of a node containing specific text.
String
required
The substring to search for in node text or content description
String?
The full content description of the found node, or null if not found
Example:

Keyboard Actions

Press Enter Key

Simulate pressing the Enter/Return key.
Example:
This method tries three strategies in order:
  1. Find and click a visible Enter/Done/Send button
  2. Send ACTION_IME_ENTER to the focused field (API 33+)
  3. Tap at the typical Enter key position as fallback

Deletion Operations

Delete by Resource ID

Clear text from a field identified by resource ID.
String
required
The resource ID of the field to clear
Example:

Delete by Class Name

Clear text from all fields matching a class name.
String
required
The class name of fields to clear
Example:

Specialized Click Methods

Click Element by Area

Click an element based on its pixel area (width × height).
Int
required
The target area in square pixels
Example:
Helper method for width/height:

Click Element by Area Range

Click an element whose area falls within a range.
Int
required
Minimum area in square pixels
Int
required
Maximum area in square pixels
Example:

App-Specific Methods

These methods are designed for specific apps but demonstrate advanced techniques: Clicks the first thumbnail in a TikTok-style gallery view.

Click Video Upload Button

Finds and clicks the video upload button using multiple fallback strategies.

Click First Song

Clicks the first item in a RecyclerView (music list).

Click Bio Button

Clicks a button whose content description starts with “Bio”.

Find Toggle Near Text

Finds a toggle element (switch, checkbox) near text containing specific keywords.

Best Practices

Use the most specific search method available (View ID > Content Description > Text)
Always check for null results when using find methods
Add small delays between text input and clicking to allow UI to update
View IDs may change between app versions - test automation regularly
For production automation, prefer content descriptions over text as they’re more stable across localizations