browser_click
Click elements on web pages to automate interactions. Specify target elements and click options like double-click or button type for precise control.
Instructions
Perform click on a web page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| element | Yes | Human-readable element description used to obtain permission to interact with the element | |
| ref | Yes | Exact target element reference from the page snapshot | |
| doubleClick | No | Whether to perform a double click instead of a single click | |
| button | No | Button to click, defaults to left |
Implementation Reference
- src/tools/snapshot.ts:59-78 (handler)Handler function that resolves the element locator from the provided reference and parameters, generates corresponding Playwright code for click or double-click, and executes the action while waiting for completion.handle: async (tab, params, response) => { response.setIncludeSnapshot(); const locator = await tab.refLocator(params); const button = params.button; const buttonAttr = button ? `{ button: '${button}' }` : ''; if (params.doubleClick) response.addCode(`await page.${await generateLocator(locator)}.dblclick(${buttonAttr});`); else response.addCode(`await page.${await generateLocator(locator)}.click(${buttonAttr});`); await tab.waitForCompletion(async () => { if (params.doubleClick) await locator.dblclick({ button }); else await locator.click({ button }); }); },
- src/tools/snapshot.ts:51-57 (schema)Schema definition for the browser_click tool, including name, title, description, input schema (clickSchema which extends elementSchema), and type.schema: { name: 'browser_click', title: 'Click', description: 'Perform click on a web page', inputSchema: clickSchema, type: 'destructive', },
- src/tools.ts:36-52 (registration)Registration of all tools including the browser_click tool (via ...snapshot import at line 27), collected into allTools array used by filteredTools and browser backend.export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];
- src/tools/snapshot.ts:44-47 (schema)Specific input schema for click tool options, extending the shared elementSchema.const clickSchema = elementSchema.extend({ doubleClick: z.boolean().optional().describe('Whether to perform a double click instead of a single click'), button: z.enum(['left', 'right', 'middle']).optional().describe('Button to click, defaults to left'), });
- src/browserServerBackend.ts:50-50 (registration)In the BrowserServerBackend constructor, tools are set using filteredTools which includes browser_click, and later exposed via tools() and called in callTool.this._tools = filteredTools(config);