type
Simulate user text input into web elements using CSS selectors for automated browser testing and interaction validation.
Instructions
Type text into an input field identified by a CSS selector
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector of the input field | |
| text | Yes | Text to type |
Implementation Reference
- src/browser.ts:61-70 (handler)Core implementation of the 'type' tool handler using Puppeteer to wait for and type text into a CSS selector.async type(selector: string, text: string) { const page = await this.init(); try { await page.waitForSelector(selector, { timeout: 5000 }); await page.type(selector, text); return `Typed "${text}" into ${selector}`; } catch (e: any) { throw new Error(`Failed to type into ${selector}: ${e.message}`); } }
- src/index.ts:126-128 (handler)Dispatch handler in the MCP call tool request that invokes the browserManager.type method.case "type": result = await browserManager.type(String(args?.selector), String(args?.text)); break;
- src/index.ts:51-58 (schema)Input schema definition for the 'type' tool, specifying selector and text parameters.inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector of the input field" }, text: { type: "string", description: "Text to type" }, }, required: ["selector", "text"], },
- src/index.ts:48-59 (registration)Registration of the 'type' tool in the TOOLS array used for listing available tools.{ name: "type", description: "Type text into an input field identified by a CSS selector", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector of the input field" }, text: { type: "string", description: "Text to type" }, }, required: ["selector", "text"], }, },