Android tap Element
android_tap_elementTap a UI element by its resource-id or visible label/text on an Android device, bypassing coordinate-based taps and duplicate selectors. Confirm success with expected text appearing or disappearing.
Instructions
Tap a view on a connected Android device or emulator by IDENTITY instead of raw coordinates: identifier matches the resource-id, label matches the text OR the content-desc (Android splits what one accessibility label holds elsewhere, so one selector covers both). The selector matches exactly first, then case-insensitively as a substring. Nested duplicates — a list row mirroring its text onto a child TextView inside a clickable container — collapse to ONE target, the outermost clickable node of that chain; if several distinct nodes still match, the error lists every candidate with its text, resource-id and bounds. Only on-screen, enabled nodes are tapped: when the only match is scrolled out of view or disabled the tool FAILS with an actionable message instead of tapping dead coordinates (allow_offscreen=true taps an off-screen match anyway; disabled nodes always refuse). The tap lands on the node center, then after ~300 ms a fresh screenshot is captured with the same summary shape as android_interact. To CONFIRM the tap landed, pass expect_text (text that should appear) or expect_gone (text that should disappear) — the tool polls the screen OCR for ~4 s and reports expected.matched in the SAME call. Do NOT screenshot-and-compare pixels to check whether a tap worked; use these assertions instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label | No | Visible text or content-desc to match, e.g. "Network & internet". Exact match first, then case-insensitive substring. Icon-only buttons carry a content-desc but no text. | |
| serial | No | Target device serial from android_devices. Defaults to the currently streamed device, else the only connected one. | |
| identifier | No | resource-id to match, e.g. "com.android.settings:id/search_action_bar" (the ":id/name" tail is usually enough as a substring). Exact match first, then case-insensitive substring. | |
| expect_gone | No | Optional text that should DISAPPEAR after the tap. Mutually exclusive with expect_text; reported as expected.matched (true = the text is gone). | |
| expect_text | No | Optional text that should APPEAR after the tap. The tool polls screen OCR for up to ~4 s and reports expected.matched — one round trip instead of tap + screenshot + manual compare. | |
| allow_offscreen | No | Allow tapping a node whose bounds lie outside the screen (a recycled list row that uiautomator still reports) — the tap lands at the recorded coordinates whatever is displayed there. Default false: such a match fails with a scroll-it-into-view error. Disabled nodes are always refused, regardless of this flag. |