playwright_click
Click elements on web pages using CSS selectors for browser automation with Playwright.
Instructions
Click an element on the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for the element to click |
Implementation Reference
- src/tools/browser/interaction.ts:11-21 (handler)ClickTool class implements the core logic for the playwright_click tool, using Playwright's page.click method on the provided CSS selector.export class ClickTool extends BrowserToolBase { /** * Execute the click tool */ async execute(args: any, context: ToolContext): Promise<ToolResponse> { return this.safeExecute(context, async (page) => { await page.click(args.selector); return createSuccessResponse(`Clicked element: ${args.selector}`); }); } }
- src/tools.ts:121-130 (schema)MCP tool definition including name, description, and input schema for playwright_click, requiring a 'selector' parameter.name: "playwright_click", description: "Click an element on the page", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for the element to click" }, }, required: ["selector"], }, },
- src/toolHandler.ts:392-392 (registration)Instantiation of the ClickTool instance in initializeTools function.if (!clickTool) clickTool = new ClickTool(server);
- src/toolHandler.ts:585-586 (registration)Dispatch in handleToolCall switch statement that routes playwright_click calls to the ClickTool's execute method.case "playwright_click": return await clickTool.execute(args, context);
- src/tools.ts:496-496 (registration)Inclusion of playwright_click in BROWSER_TOOLS array, ensuring browser context is prepared before execution."playwright_click",