browser_type
Simulate text input into specific web elements using structured accessibility snapshots. Configure options for slow typing or automatic submission to replicate user interactions accurately.
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-83 (handler)The core handler function for the 'browser_type' tool. It resolves a locator from params, then fills the element with the provided text (using fill() or pressSequentially() if slowly), and optionally presses Enter if submit is true.handle: async (tab, params, response) => { const locator = await tab.refLocator(params); await tab.waitForCompletion(async () => { if (params.slowly) { response.setIncludeSnapshot(); response.addCode(`await page.${await generateLocator(locator)}.pressSequentially(${javascript.quote(params.text)});`); await locator.pressSequentially(params.text); } else { 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)Schema definition for the 'browser_type' tool, including the input schema (typeSchema extending elementSchema) and the tool schema with name, title, description, inputSchema reference, and type.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)Registration of all tools in the allTools array, which spreads the exports from the keyboard module (providing browser_type and browser_press_key) among other tools. This array is used to provide tools to the MCP server.export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];