playwright_click
Automate browser interactions by clicking elements using CSS selectors with Playwright on the MCP Browser Automation Server.
Instructions
Click an element on the page
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>"
},
"name": "playwright_click"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for element to click |
Implementation Reference
- src/toolsHandler.ts:175-197 (handler)The handler implementation for the 'playwright_click' tool. It uses Playwright's page.click to click the element specified by the CSS selector and returns success or error messages.
case "playwright_click": try { await page!.click(args.selector); return { toolResult: { content: [{ type: "text", text: `Clicked: ${args.selector}`, }], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `Failed to click ${args.selector}: ${(error as Error).message}`, }], isError: true, }, }; } - src/tools.ts:33-43 (schema)The tool schema definition including name, description, and input schema 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 element to click" }, }, required: ["selector"], }, }, - src/tools.ts:152-160 (helper)Array listing browser-requiring tools, including 'playwright_click', 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" ];