browser_click
Click on web page elements to automate browser interactions, using element references for precise targeting in Playwright automation workflows.
Instructions
Click on an element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| element | Yes | Human-readable element description | |
| ref | Yes | Exact target element reference from page snapshot |
Implementation Reference
- src/server.ts:236-251 (handler)The core handler function that executes the browser_click tool logic. It ensures a browser page is open and performs a click action (currently a placeholder clicking on 'body').private async handleClick(element: string, ref: string) { await this.ensureBrowser(); // Simple click implementation - in a real implementation, // you would parse the ref to find the actual element await this.browserState.page!.click('body'); // Placeholder return { content: [ { type: 'text', text: `Clicked on ${element}`, }, ], }; }
- src/server.ts:82-99 (registration)Registration of the browser_click tool in the list of available tools, including its name, description, and input schema definition.{ name: 'browser_click', description: 'Click on an element', inputSchema: { type: 'object', properties: { element: { type: 'string', description: 'Human-readable element description', }, ref: { type: 'string', description: 'Exact target element reference from page snapshot', }, }, required: ['element', 'ref'], }, },
- src/server.ts:163-165 (handler)Dispatch case in the CallToolRequestSchema handler that routes browser_click calls to the handleClick method.case 'browser_click': return await this.handleClick(args?.element as string, args?.ref as string);
- src/server.ts:191-200 (helper)Helper method used by browser_click handler to ensure a browser and page are initialized.private async ensureBrowser() { if (!this.browserState.browser) { this.browserState.browser = await chromium.launch({ headless: false, }); } if (!this.browserState.page) { this.browserState.page = await this.browserState.browser.newPage(); } }