type_text
Enter text into input fields using CSS selectors to automate form filling during web testing and debugging workflows.
Instructions
Digita texto em um campo de input
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clearFirst | No | Limpar campo antes de digitar | |
| selector | Yes | Seletor CSS do campo de input | |
| text | Yes | Texto para digitar |
Implementation Reference
- src/browserTools.ts:504-524 (handler)The handler function for the 'type_text' tool. It types text into a selector, optionally clearing first by triple-clicking, using Puppeteer's page.type and page.click methods.export async function handleTypeText(args: unknown, currentPage: Page): Promise<ToolResponse> { const typedArgs = args as unknown as TypeTextArgs; const { selector, text, clearFirst = true } = typedArgs; if (clearFirst) { await currentPage.click(selector, { clickCount: 3 }); } await currentPage.type(selector, text); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Texto digitado em: ${selector}`, }), }, ], }; }
- src/types.ts:80-84 (schema)TypeScript interface defining the input arguments for the type_text tool: selector (CSS selector for input field), text (string to type), clearFirst (optional boolean to clear field first).export interface TypeTextArgs { selector: string; text: string; clearFirst?: boolean; }
- src/tools.ts:212-233 (registration)MCP tool registration in the tools array, including name, description, and inputSchema for validation.name: 'type_text', description: 'Digita texto em um campo de input', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'Seletor CSS do campo de input', }, text: { type: 'string', description: 'Texto para digitar', }, clearFirst: { type: 'boolean', description: 'Limpar campo antes de digitar', default: true, }, }, required: ['selector', 'text'], }, },
- src/index.ts:107-110 (registration)Dispatch logic in the MCP server request handler that routes 'type_text' calls to the handleTypeText function, ensuring browser page is initialized.case 'type_text': { const currentPage = await initBrowser(); return await handleTypeText(args, currentPage); }