Skip to main content
Glama
Radek44
by Radek44

click_element

Automate clicking on UI elements in Tauri desktop applications using CSS selectors to interact with buttons, links, and other interface components for testing and workflow automation.

Instructions

Click a UI element identified by a CSS selector

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector to identify the element to click (e.g., "#button-id", ".button-class", "button[name=submit]")

Implementation Reference

  • The main handler function for the 'click_element' tool. It receives the driver and parameters, calls the driver's clickElement method, and returns a standardized ToolResponse with success status and message or error.
    export async function clickElement( driver: TauriDriver, params: ElementSelector ): Promise<ToolResponse<{ message: string }>> { try { await driver.clickElement(params.selector); return { success: true, data: { message: `Clicked element: ${params.selector}`, }, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error), }; } }
  • Defines the tool schema including name, description, and input schema (CSS selector) for 'click_element' in the ListTools response.
    { name: 'click_element', description: 'Click a UI element identified by a CSS selector', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector to identify the element to click (e.g., "#button-id", ".button-class", "button[name=submit]")', }, }, required: ['selector'], }, },
  • src/index.ts:262-271 (registration)
    Dispatches the 'click_element' tool call to the clickElement handler function in the CallToolRequest handler switch statement.
    case 'click_element': { const result = await clickElement(driver, args as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], };
  • Low-level helper method in TauriDriver class that uses WebDriverIO to locate and click the element by CSS selector.
    async clickElement(selector: string): Promise<void> { this.ensureAppRunning(); const element = await this.appState.browser!.$(selector); if (!(await element.isExisting())) { throw new Error(`Element not found: ${selector}`); } await element.click(); }

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/Radek44/mcp-tauri-automation'

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