click
Automate clicking on specific web elements using CSS selectors within the Chromium ARM64 Browser, enabling precise browser interactions and enhanced web testing workflows.
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
- index.js:637-675 (handler)The primary handler function for the 'click' MCP tool. It uses the Chrome DevTools Protocol (CDP) to query the DOM for the given CSS selector, retrieves the element's bounding box, calculates the center point, and simulates a left mouse click by dispatching Input.dispatchMouseEvent for mousePressed and mouseReleased.async click(selector) { await this.ensureChromium(); // Find element const doc = await this.sendCDPCommand('DOM.getDocument'); const element = await this.sendCDPCommand('DOM.querySelector', { nodeId: doc.root.nodeId, selector }); if (!element.nodeId) { throw new Error(`Element not found: ${selector}`); } // Get element box const box = await this.sendCDPCommand('DOM.getBoxModel', { nodeId: element.nodeId }); const quad = box.model.content; const x = (quad[0] + quad[4]) / 2; const y = (quad[1] + quad[5]) / 2; // Click await this.sendCDPCommand('Input.dispatchMouseEvent', { type: 'mousePressed', x, y, button: 'left', clickCount: 1 }); await this.sendCDPCommand('Input.dispatchMouseEvent', { type: 'mouseReleased', x, y, button: 'left', clickCount: 1 }); return { content: [{ type: 'text', text: `Clicked element: ${selector}` }], }; }
- index.js:138-151 (schema)The JSON schema definition for the 'click' tool input, specifying that it requires a single 'selector' property of type string.{ name: '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'], }, },
- index.js:355-356 (registration)The dispatch registration in the CallToolRequestSchema handler's switch statement that routes 'click' tool calls to the click method.case 'click': return await this.click(args.selector);
- arm64_browser.py:85-87 (helper)Python wrapper helper in arm64_browser.py that calls the MCP 'click' tool.def click(selector: str) -> str: """Click an element by CSS selector""" return call_mcp_tool("click", selector=selector)
- chromium_tool.py:79-86 (helper)Python class method helper in chromium_tool.py that proxies the 'click' tool call to the MCP server.def click(self, selector: str) -> str: """Click an element by CSS selector.""" result = self._call_mcp_server("click", {"selector": selector}) if "error" in result: return f"Error: {result['error']}" content = result.get("content", [{}]) return content[0].get("text", "Element clicked")