browser_type
Simulate text input into editable web elements, with options to submit or type slowly, using structured accessibility snapshots for precise interaction.
Instructions
Type text into editable element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| element | Yes | Human-readable element description used to obtain permission to interact with the element | |
| ref | Yes | Exact target element reference from the page snapshot | |
| slowly | No | Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once. | |
| submit | No | Whether to submit entered text (press Enter after) | |
| text | Yes | Text to type into the element |
Implementation Reference
- src/tools/keyboard.ts:64-85 (handler)The handler function that executes the browser_type tool: types text into a locator-resolved element, with options for slow typing (pressSequentially) or fast fill, and optional Enter press for submit.handle: async (tab, params, response) => { const locator = await tab.refLocator(params); await tab.waitForCompletion(async () => { if (params.slowly) { response.setIncludeSnapshot(); response.addCode(`// Press "${params.text}" sequentially into "${params.element}"`); response.addCode(`await page.${await generateLocator(locator)}.pressSequentially(${javascript.quote(params.text)});`); await locator.pressSequentially(params.text); } else { response.addCode(`// Fill "${params.text}" into "${params.element}"`); response.addCode(`await page.${await generateLocator(locator)}.fill(${javascript.quote(params.text)});`); await locator.fill(params.text); } if (params.submit) { response.setIncludeSnapshot(); response.addCode(`await page.${await generateLocator(locator)}.press('Enter');`); await locator.press('Enter'); } }); },
- src/tools/keyboard.ts:48-62 (schema)Type schema (lines 48-52) and tool schema (56-62) defining inputs for browser_type: element locator, text to type, optional submit and slowly flags.const typeSchema = elementSchema.extend({ text: z.string().describe('Text to type into the element'), submit: z.boolean().optional().describe('Whether to submit entered text (press Enter after)'), slowly: z.boolean().optional().describe('Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.'), }); const type = defineTabTool({ capability: 'core', schema: { name: 'browser_type', title: 'Type text', description: 'Type text into editable element', inputSchema: typeSchema, type: 'destructive', },
- src/tools.ts:36-52 (registration)Includes keyboard tools (containing browser_type) via spread operator at line 43 into the allTools array exported for use in the tool system.export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];
- src/tools.ts:23-23 (registration)Imports the keyboard module which exports the browser_type tool implementation.import keyboard from './tools/keyboard.js';