browser_fill
Automate form filling by entering specified text into a targeted web input field using a CSS selector, streamlining repetitive data entry tasks in browser automation workflows.
Instructions
Fill a form input with text
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for input field | |
| value | Yes | Text to enter in the field |
Implementation Reference
- src/executor.ts:378-402 (handler)The handler function for 'browser_fill' tool. It waits for the CSS selector to appear, fills the input field with the specified value using Playwright's page.fill(), and returns a success message or error.async function handleBrowserFill(page: Page, args: any): Promise<{ toolResult: CallToolResult }> { try { await page.waitForSelector(args.selector); await page.fill(args.selector, args.value); return { toolResult: { content: [{ type: "text", text: `Filled ${args.selector} with: ${args.value}`, }], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `Fill operation failed on ${args.selector}: ${(error as Error).message}`, }], isError: true, }, }; } }
- src/tools.ts:84-95 (registration)Registration of the 'browser_fill' tool in the registerTools() function, including name, description, and input schema.{ name: "browser_fill", description: "Fill a form input with text", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for input field" }, value: { type: "string", description: "Text to enter in the field" } }, required: ["selector", "value"] } },
- src/tools.ts:87-94 (schema)Input schema for the 'browser_fill' tool defining the required selector (CSS selector for input) and value (text to enter).inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for input field" }, value: { type: "string", description: "Text to enter in the field" } }, required: ["selector", "value"] }
- src/executor.ts:197-198 (registration)Dispatch/registration case in the executeToolCall switch statement that calls the handleBrowserFill handler for 'browser_fill'.case "browser_fill": return await handleBrowserFill(activePage!, args);
- src/tools.ts:7-7 (registration)'browser_fill' included in BROWSER_TOOLS constant array, used to identify browser tools in executor."browser_fill",