playwright_fill
Automate browser tasks by filling input fields with specified values using CSS selectors, enabling streamlined interaction with web elements via the MCP Browser Automation Server.
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
- src/toolsHandler.ts:199-222 (handler)Handler implementation for the playwright_fill tool. It waits for the selector to appear and then fills the input field with the provided value using Playwright's page.fill method.case "playwright_fill": 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: `Failed to type ${args.selector}: ${(error as Error).message}`, }], isError: true, }, }; }
- src/tools.ts:44-55 (schema)Schema definition for the playwright_fill tool, specifying the input parameters selector and value.{ name: "playwright_fill", 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"], }, },
- src/index.ts:23-26 (registration)Registration of tools including playwright_fill via createToolDefinitions() and setupRequestHandlers.const TOOLS = createToolDefinitions(); // Setup request handlers setupRequestHandlers(server, TOOLS);
- src/tools.ts:152-160 (helper)Helper array BROWSER_TOOLS that includes playwright_fill, used to determine if browser launch is required.export const BROWSER_TOOLS = [ "playwright_navigate", "playwright_screenshot", "playwright_click", "playwright_fill", "playwright_select", "playwright_hover", "playwright_evaluate" ];