Skip to main content
Glama

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
NameRequiredDescriptionDefault
selectorYesElement selector to find and click
device_idNoDevice 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;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/divineDev-dotcom/android_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server