Skip to main content
Glama
Radek44
by Radek44

click_element

Automate UI interactions in Tauri desktop applications by clicking elements identified with CSS selectors, enabling automated testing without manual input.

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

  • Primary handler function for the 'click_element' tool. It receives the driver instance and parameters, delegates to the driver's clickElement method, and formats the response as ToolResponse with success/error handling.
    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), }; } }
  • Core implementation of element clicking using WebDriverIO. Finds the element by CSS selector, checks existence, and performs the click action.
    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(); }
  • src/index.ts:102-115 (registration)
    Registers the 'click_element' tool in the MCP ListTools response, including name, description, and input schema.
    { 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'], }, },
  • MCP CallToolRequest dispatcher case for 'click_element', invokes the clickElement handler and returns the result as MCP content.
    case 'click_element': { const result = await clickElement(driver, args as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • Input schema definition for the 'click_element' tool, specifying the required 'selector' parameter.
    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'], },

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