click_element
Tap Android UI elements by matching selectors like text, resource ID, or class name for reliable automation without using raw coordinates.
Instructions
Find a UI element matching the selector and tap its center. This is the preferred way to interact with UI elements rather than using raw coordinates.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | Element selector to find and click | |
| device_id | No | Device serial number |
Implementation Reference
- The implementation of the click_element tool logic, which finds an element by selector, taps its center, and invalidates the UI cache.
export async function clickElement( selector: ElementSelector, deviceId?: string ): Promise<FoundElement> { const resolved = await deviceManager.resolveDeviceId(deviceId); const element = await findElement(selector, resolved); await tap(element.bounds.centerX, element.bounds.centerY, resolved); // Invalidate UI tree cache since we mutated the screen invalidateUITreeCache(resolved); log.info('Element clicked', { selector, center: { x: element.bounds.centerX, y: element.bounds.centerY }, deviceId: resolved, }); return element; }