click
Simulate user clicks on web elements using CSS selectors for automated browser testing and interaction validation.
Instructions
Click an element on the page identified by a CSS selector
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector of the element to click |
Implementation Reference
- src/browser.ts:50-59 (handler)Core handler function that executes the click logic using Puppeteer: waits for the selector and performs page.click.async click(selector: string) { const page = await this.init(); try { await page.waitForSelector(selector, { timeout: 5000 }); await page.click(selector); return `Clicked element: ${selector}`; } catch (e: any) { throw new Error(`Failed to click ${selector}: ${e.message}`); } }
- src/index.ts:123-125 (handler)MCP tool call handler dispatch for 'click' tool, invoking browserManager.click.case "click": result = await browserManager.click(String(args?.selector)); break;
- src/index.ts:37-47 (schema)Input schema definition for the 'click' tool, specifying the 'selector' parameter.{ name: "click", description: "Click an element on the page identified by a CSS selector", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector of the element to click" }, }, required: ["selector"], }, },
- src/index.ts:106-110 (registration)Tool registration via ListToolsRequestHandler, which returns the TOOLS array including 'click'.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS, }; });