type_text
Automate web interactions by typing text into specified input fields using CSS selectors. Customize keystroke delays for precise control over text input.
Instructions
Type text into an input field
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| delay | No | Delay between keystrokes in milliseconds | |
| selector | Yes | CSS selector for the input element | |
| text | Yes | Text to type |
Implementation Reference
- src/index.ts:501-517 (handler)Handler implementation for the 'type_text' tool. Validates input with TypeTextSchema, then uses Playwright's currentPage.fill() to input the text into the specified selector.case 'type_text': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = TypeTextSchema.parse(args); await currentPage.fill(params.selector, params.text); return { content: [ { type: 'text', text: `Typed "${params.text}" into element: ${params.selector}` } ] }; }
- src/index.ts:33-37 (schema)Zod schema defining the input parameters for the type_text tool: selector (string), text (string), delay (number, default 100ms). Note: delay is not used in the handler.const TypeTextSchema = z.object({ selector: z.string(), text: z.string(), delay: z.number().default(100) });
- src/index.ts:196-218 (registration)Tool registration in the ListTools response, defining name, description, and inputSchema matching the Zod schema.{ name: 'type_text', description: 'Type text into an input field', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the input element' }, text: { type: 'string', description: 'Text to type' }, delay: { type: 'number', default: 100, description: 'Delay between keystrokes in milliseconds' } }, required: ['selector', 'text'] } },