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
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector to identify the element to click (e.g., "#button-id", ".button-class", "button[name=submit]") |
Implementation Reference
- src/tools/interact.ts:11-30 (handler)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), }; } }
- src/tauri-driver.ts:120-129 (handler)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'], }, },
- src/index.ts:262-272 (handler)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), }, ], }; }
- src/index.ts:105-114 (schema)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'], },