type_text
Automate text input into desktop application fields using CSS selectors to specify target elements and define text content for testing workflows.
Instructions
Type text into an input field or editable element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector to identify the input element | |
| text | Yes | Text to type into the element | |
| clear | No | Whether to clear existing text before typing. Default: false |
Implementation Reference
- src/tools/interact.ts:35-54 (handler)Main handler function for the 'type_text' tool. Calls the driver's typeText method and wraps the result in a ToolResponse.export async function typeText( driver: TauriDriver, params: TypeTextParams ): Promise<ToolResponse<{ message: string }>> { try { await driver.typeText(params.selector, params.text, params.clear); return { success: true, data: { message: `Typed text into element: ${params.selector}`, }, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error), }; } }
- src/types.ts:72-79 (schema)TypeScript interface defining the input parameters for the type_text tool.export interface TypeTextParams { /** CSS selector for the input element */ selector: string; /** Text to type */ text: string; /** Whether to clear existing text first */ clear?: boolean; }
- src/index.ts:116-138 (registration)Tool registration in the MCP server, including name 'type_text' and input schema matching TypeTextParams.{ name: 'type_text', description: 'Type text into an input field or editable element', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector to identify the input element', }, text: { type: 'string', description: 'Text to type into the element', }, clear: { type: 'boolean', description: 'Whether to clear existing text before typing. Default: false', default: false, }, }, required: ['selector', 'text'], }, },
- src/index.ts:274-284 (registration)Dispatch handler in the CallToolRequestSchema switch statement that invokes the typeText handler.case 'type_text': { const result = await typeText(driver, args as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/tauri-driver.ts:134-147 (helper)Low-level implementation in TauriDriver class that performs the actual element selection, clearing, and value setting using WebDriverIO.async typeText(selector: string, text: string, clear: boolean = false): Promise<void> { this.ensureAppRunning(); const element = await this.appState.browser!.$(selector); if (!(await element.isExisting())) { throw new Error(`Element not found: ${selector}`); } if (clear) { await element.clearValue(); } await element.setValue(text); }