browser_click
Interact with web elements by performing single or double clicks using precise element references. Supports left, right, and middle button clicks for targeted actions on web pages.
Instructions
Perform click on a web page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| button | No | Button to click, defaults to left | |
| doubleClick | No | Whether to perform a double click instead of a single click | |
| 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 |
Implementation Reference
- src/tools/snapshot.ts:59-78 (handler)The handler function for the browser_click tool. It resolves the element locator, generates code for click or double-click, adds it to the response, and executes the action using Playwright.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:39-57 (schema)Schema definitions: elementSchema (base), clickSchema (extends for click params), and the tool schema with name 'browser_click' using inputSchema: clickSchema.export const elementSchema = z.object({ element: z.string().describe('Human-readable element description used to obtain permission to interact with the element'), ref: z.string().describe('Exact target element reference from the page snapshot'), }); 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'), }); const click = defineTabTool({ capability: 'core', 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 the browser_click tool by including the snapshot tools module (which exports the click tool) in the allTools array.export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];
- src/tools/snapshot.ts:160-166 (registration)Local registration/export of the click tool (browser_click) as part of the snapshot tools module default export array.export default [ snapshot, click, drag, hover, selectOption, ];