browser_type
Enables automated text input into specified elements within browser instances, supporting delays and timeouts for precise control in parallel testing or automation workflows.
Instructions
Type text into an element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| delay | No | Input delay in milliseconds | |
| instanceId | Yes | Instance ID | |
| selector | Yes | Element selector | |
| text | Yes | Text to input | |
| timeout | No | Timeout in milliseconds |
Implementation Reference
- src/tools.ts:722-744 (handler)Core handler function that executes the tool logic by typing text into the specified page element using Playwright's page.type() method.private async type(instanceId: string, selector: string, text: string, options: TypeOptions): Promise<ToolResult> { const instance = this.browserManager.getInstance(instanceId); if (!instance) { return { success: false, error: `Instance ${instanceId} not found` }; } try { const typeOptions: any = {}; if (options.delay) typeOptions.delay = options.delay; if (options.timeout) typeOptions.timeout = options.timeout; await instance.page.type(selector, text, typeOptions); return { success: true, data: { selector, text, typed: true }, instanceId }; } catch (error) { return { success: false, error: `Type failed: ${error instanceof Error ? error.message : error}`, instanceId }; }
- src/tools.ts:208-235 (schema)Input schema defining parameters for the browser_type tool: instanceId (required), selector (required), text (required), delay (optional), timeout (optional).inputSchema: { type: 'object', properties: { instanceId: { type: 'string', description: 'Instance ID' }, selector: { type: 'string', description: 'Element selector', }, text: { type: 'string', description: 'Text to input', }, delay: { type: 'number', description: 'Input delay in milliseconds', default: 0 }, timeout: { type: 'number', description: 'Timeout in milliseconds', default: 30000 } }, required: ['instanceId', 'selector', 'text'] }
- src/tools.ts:206-236 (registration)Tool registration object defining 'browser_type' tool, including name, description, and input schema. Returned by BrowserTools.getTools() for MCP server.name: 'browser_type', description: 'Type text into an element', inputSchema: { type: 'object', properties: { instanceId: { type: 'string', description: 'Instance ID' }, selector: { type: 'string', description: 'Element selector', }, text: { type: 'string', description: 'Text to input', }, delay: { type: 'number', description: 'Input delay in milliseconds', default: 0 }, timeout: { type: 'number', description: 'Timeout in milliseconds', default: 30000 } }, required: ['instanceId', 'selector', 'text'] } },
- src/types.ts:66-69 (schema)TypeScript interface defining optional parameters (delay, timeout) used in the browser_type tool handler.export interface TypeOptions { delay?: number; timeout?: number; }
- src/server.ts:40-45 (registration)MCP server registration for listing tools, which exposes the 'browser_type' tool via BrowserTools.getTools().this.server.setRequestHandler(ListToolsRequestSchema, async () => { const tools = this.browserTools.getTools(); return { tools: tools, }; });