Skip to main content
Glama

playwright_fill

Fill input fields on web pages using a CSS selector and specified value. Integrates with the Playwright MCP Server for browser automation tasks.

Instructions

fill out an input field

Input Schema

NameRequiredDescriptionDefault
selectorYesCSS selector for input field
valueYesValue to fill

Input Schema (JSON Schema)

{ "properties": { "selector": { "description": "CSS selector for input field", "type": "string" }, "value": { "description": "Value to fill", "type": "string" } }, "required": [ "selector", "value" ], "type": "object" }

Implementation Reference

  • FillTool class: the core handler that executes page.waitForSelector and page.fill for the playwright_fill tool
    export class FillTool extends BrowserToolBase { /** * Execute the fill tool */ async execute(args: any, context: ToolContext): Promise<ToolResponse> { return this.safeExecute(context, async (page) => { await page.waitForSelector(args.selector); await page.fill(args.selector, args.value); return createSuccessResponse(`Filled ${args.selector} with: ${args.value}`); }); } }
  • Tool schema definition including name, description, and input schema for validation
    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"], }, },
  • Dispatch/registration in main tool handler switch statement calling FillTool.execute
    case "playwright_fill": return await fillTool.execute(args, context);
  • Initialization of the FillTool instance
    if (!fillTool) fillTool = new FillTool(server);
  • Code generation helper for translating playwright_fill actions to Playwright test code
    case 'playwright_fill': return this.generateFillStep(parameters); case 'playwright_click': return this.generateClickStep(parameters); case 'playwright_screenshot': return this.generateScreenshotStep(parameters); case 'playwright_expect_response': return this.generateExpectResponseStep(parameters); case 'playwright_assert_response': return this.generateAssertResponseStep(parameters); case 'playwright_hover': return this.generateHoverStep(parameters); case 'playwright_select': return this.generateSelectStep(parameters); case 'playwright_custom_user_agent': return this.generateCustomUserAgentStep(parameters); default: console.warn(`Unsupported tool: ${toolName}`); return null; } } private generateNavigateStep(parameters: Record<string, unknown>): string { const { url, waitUntil } = parameters; const options = waitUntil ? `, { waitUntil: '${waitUntil}' }` : ''; return ` // Navigate to URL await page.goto('${url}'${options});`; } private generateFillStep(parameters: Record<string, unknown>): string { const { selector, value } = parameters; return ` // Fill input field await page.fill('${selector}', '${value}');`; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pvinis/mcp-playwright-stealth'

If you have feedback or need assistance with the MCP directory API, please join our Discord server