playwright_fill
Fill input fields on web pages using CSS selectors to automate form completion during browser automation tasks.
Instructions
Fill out an input field
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"selector": "<selector>",
"value": "<value>"
},
"name": "playwright_fill"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for input field | |
| value | Yes | Value to fill |
Implementation Reference
- src/playwright_server/server.py:249-259 (handler)The FillToolHandler class that implements the core logic for the 'playwright_fill' tool. It fills an input field specified by a CSS selector with the provided value using Playwright's page.locator().fill() method.
class FillToolHandler(ToolHandler): async def handle(self, name: str, arguments: dict | None) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: if not self._sessions: return [types.TextContent(type="text", text="No active session. Please create a new session first.")] session_id = list(self._sessions.keys())[-1] page = self._sessions[session_id]["page"] selector = arguments.get("selector") value = arguments.get("value") await page.locator(selector).fill(value) return [types.TextContent(type="text", text=f"Filled element with selector {selector} with value {value}")] - The JSON schema definition for the 'playwright_fill' tool, defining required 'selector' and 'value' string parameters.
types.Tool( 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/playwright_server/server.py:334-344 (registration)The tool_handlers dictionary registers an instance of FillToolHandler for the 'playwright_fill' tool name, which is used by the @server.call_tool() handler to dispatch calls.
tool_handlers = { "playwright_navigate": NavigateToolHandler(), "playwright_screenshot": ScreenshotToolHandler(), "playwright_click": ClickToolHandler(), "playwright_fill": FillToolHandler(), "playwright_evaluate": EvaluateToolHandler(), "playwright_click_text": ClickTextToolHandler(), "playwright_get_text_content": GetTextContentToolHandler(), "playwright_get_html_content": GetHtmlContentToolHandler(), "playwright_new_session":NewSessionToolHandler(), }