browser_click
Simulate clicks on web page elements to test interactions and verify WCAG compliance, ensuring accessibility across user workflows with precise element targeting.
Instructions
Perform click on a web page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| 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:128-147 (handler)Executes the browser_click tool: resolves element locator from params, generates code snippet for click/dblclick, performs the action via Playwright on the tab's page.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:108-126 (schema)Defines Zod schemas for input validation: base elementSchema (element desc, ref), clickSchema extending it with doubleClick and button options. Used in tool schema with name 'browser_click'.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:38-56 (registration)Registers the browser_click tool by including the snapshot module's tools (via ...snapshot) in the allTools array, which is filtered into _tools used by BrowserServerBackend for MCP listTools().export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...form, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ...verify, ];
- src/browserServerBackend.ts:38-42 (registration)In BrowserServerBackend constructor, sets this._tools = filteredTools(config), which includes browser_click, used for dispatching calls and listing in MCP.constructor(config: FullConfig, factory: BrowserContextFactory) { this._config = config; this._browserContextFactory = factory; this._tools = filteredTools(config); }
- src/browserServerBackend.ts:61-63 (registration)BrowserServerBackend.listTools() converts tool schemas including browser_click to MCP Tool format for registration with the MCP server.async listTools(): Promise<mcpServer.Tool[]> { return this._tools.map(tool => toMcpTool(tool.schema)); }