browser_fill
Automatically populate web form fields with specified values using CSS selectors to simulate user input during security testing.
Instructions
Fill out an input field
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for input field | |
| value | Yes | Value to fill |
Implementation Reference
- index.ts:342-381 (handler)The handler function for the 'browser_fill' tool. It uses Playwright to locate an element by CSS selector and fills it with the provided value using pressSequentially for realistic typing simulation. Includes retry logic for strict mode violations and proper error handling.case ToolName.BrowserFill: try { await page.locator(args.selector).pressSequentially(args.value, { delay: 100 }); return { content: [{ type: "text", text: `Filled ${args.selector} with: ${args.value}`, }], isError: false, }; } catch (error) { if((error as Error).message.includes("strict mode violation")) { console.log("Strict mode violation, retrying on first element..."); try { await page.locator(args.selector).first().pressSequentially(args.value, { delay: 100 }); return { content: [{ type: "text", text: `Filled ${args.selector} with: ${args.value}`, }], isError: false, }; } catch (error) { return { content: [{ type: "text", text: `Failed (twice) to fill ${args.selector}: ${(error as Error).message}`, }], isError: true, }; } } return { content: [{ type: "text", text: `Failed to fill ${args.selector}: ${(error as Error).message}`, }], isError: true, }; }
- index.ts:100-107 (schema)Input schema definition for the browser_fill tool, specifying the required 'selector' (CSS selector for the input field) and 'value' (string to fill) parameters.inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for input field" }, value: { type: "string", description: "Value to fill" }, }, required: ["selector", "value"], },
- index.ts:97-107 (registration)Registration of the browser_fill tool in the TOOLS array, including name, description, and input schema. This array is served via ListToolsRequestSchema.{ name: ToolName.BrowserFill, description: "Fill out an input field", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for input field" }, value: { type: "string", description: "Value to fill" }, }, required: ["selector", "value"], },
- index.ts:22-35 (helper)Enum defining ToolName.BrowserFill = "browser_fill", used for tool identification in registration and dispatching.enum ToolName { BrowserNavigate = "browser_navigate", BrowserScreenshot = "browser_screenshot", BrowserClick = "browser_click", BrowserClickText = "browser_click_text", BrowserFill = "browser_fill", BrowserSelect = "browser_select", BrowserSelectText = "browser_select_text", BrowserHover = "browser_hover", BrowserHoverText = "browser_hover_text", BrowserEvaluate = "browser_evaluate", BrowserUrlReflectedXss = "broser_url_reflected_xss", BrowserUrlSqlInjection = "browser_url_sql_injection" }