Skip to main content
Glama

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
NameRequiredDescriptionDefault
selectorYesCSS selector for the element to click

Implementation Reference

  • 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}`); }); } }
  • 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"], }, },
  • Instantiation of the ClickTool instance in initializeTools function.
    if (!clickTool) clickTool = new ClickTool(server);
  • 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",

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/aakashH242/mcp-playwright'

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