playwright_fill
Fill input fields on web pages using CSS selectors and specified values. Enables precise browser automation for completing forms or updating text fields programmatically.
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)The handler function that implements the 'playwright_fill' tool logic: waits for the CSS selector to appear, fills the input field with the provided value, and returns a success or error message.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)The tool definition including name, description, and input schema for 'playwright_fill', requiring 'selector' and 'value' as strings.{ 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/tools.ts:152-160 (helper)The 'playwright_fill' tool is listed in BROWSER_TOOLS array, used to conditionally launch the browser before executing browser-interacting tools.export const BROWSER_TOOLS = [ "playwright_navigate", "playwright_screenshot", "playwright_click", "playwright_fill", "playwright_select", "playwright_hover", "playwright_evaluate" ];
- src/requestHandler.ts:59-68 (registration)Registration of tool handlers: lists all tools (including 'playwright_fill') via ListToolsRequestSchema and routes tool calls to the handleToolCall function.// List tools handler server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools, })); // Call tool handler server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}, server) ); }