click

suspend fun click(tag: String)

Executes a physical tap or click on the UI element matching the provided string tag or text.

This is the primary and simplest method for interacting with UI elements. It automatically attempts to match by explicit Compose testTag first, and falls back to matching by visible text substring.

Automatically waits for the element to become visible before attempting the click.

Example Usage

click("Submit")
click("login_button")

Parameters

tag

The testTag string or visible text of the UI element to click.

See also

(Selector)

Throws

If no visible element matching tag appears within the timeout.


suspend fun click(selector: Selector)

Executes a physical tap or click on the UI element matching the specified selector.

Use this variant when precise element targeting is required—such as matching an exact tag only (tag()), exact text only (text()), or picking a specific index when multiple elements match (atIndex(), first(), last()).

Automatically waits for the element to become visible before attempting the click.

Example Usage

// Click strictly by testTag (ignores text matching)
click(tag("submit_btn"))

// Click strictly by visible text substring
click(text("Sign In"))

// Click the 2nd matching element when multiple items exist
click(auto("Delete").atIndex(1))

Parameters

selector

The explicit Selector rule used to locate the target UI element.

See also

Throws

If no visible node matches selector within the timeout.