browser_fill
Automate vulnerability detection in web applications by filling input fields using CSS selectors and predefined values for security testing purposes.
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 within the handleToolCall switch statement. It uses Playwright to locate an input field by CSS selector and fills it with the provided value using pressSequentially for realistic typing simulation. Includes error handling and retry logic for strict mode violations.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 an object with required 'selector' (CSS selector for the input field) and 'value' (string to fill in).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-108 (registration)Registration of the browser_fill tool in the TOOLS array, which is served via ListToolsRequestSchema. Defines name as ToolName.BrowserFill ("browser_fill"), description, and input schema.{ 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 (registration)Enum definition mapping ToolName.BrowserFill to the string "browser_fill", used throughout for tool identification in registrations and handlers.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" }