playwright_click
Click elements on web pages using CSS selectors to interact with or automate actions in a browser environment. Part of the Playwright MCP Server for web automation tasks.
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:7-17 (handler)ClickTool class: core handler that executes page.click(selector) on the browser page.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:114-123 (schema)Tool schema definition including name, description, and input schema requiring 'selector'.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:468-469 (registration)Dispatch/registration in main tool handler switch statement calling ClickTool.execute()case "playwright_click": return await clickTool.execute(args, context);
- src/tools.ts:408-408 (registration)Tool name registered in BROWSER_TOOLS constant array used for conditional browser setup."playwright_click",
- Helper function in codegen generator that produces Playwright test code for click actions.private generateClickStep(parameters: Record<string, unknown>): string { const { selector } = parameters; return ` // Click element await page.click('${selector}');`; }