Skip to main content
Glama
Radek44
by Radek44

get_element_text

Extract text content from UI elements in Tauri desktop applications using CSS selectors for automation and testing workflows.

Instructions

Get the text content of an element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector to identify the element

Implementation Reference

  • The handler function that executes the get_element_text tool logic. It calls the TauriDriver's getElementText method and wraps the result in a ToolResponse.
    export async function getElementText( driver: TauriDriver, params: ElementSelector ): Promise<ToolResponse<{ text: string }>> { try { const text = await driver.getElementText(params.selector); return { success: true, data: { text, }, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error), }; } }
  • The input schema definition for the get_element_text tool, registered in the ListTools handler.
    { name: 'get_element_text', description: 'Get the text content of an element', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector to identify the element', }, }, required: ['selector'], }, },
  • src/index.ts:298-307 (registration)
    The registration/dispatch case in the CallToolRequestSchema handler that invokes the getElementText function.
    case 'get_element_text': { const result = await getElementText(driver, args as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], };
  • The underlying TauriDriver method that performs the actual element text retrieval using WebDriverIO.
    async getElementText(selector: string): Promise<string> { this.ensureAppRunning(); const element = await this.appState.browser!.$(selector); if (!(await element.isExisting())) { throw new Error(`Element not found: ${selector}`); } return await element.getText(); }

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