browser_click
Automate clicks on web elements using CSS selectors with this tool, enabling precise interaction with web pages for browser automation tasks.
Instructions
Click an element on the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for element to click |
Implementation Reference
- src/executor.ts:353-376 (handler)The core handler function for the browser_click tool. It uses Playwright's page.click() to click the element specified by the CSS selector in args.selector, returning success or error messages.async function handleBrowserClick(page: Page, args: any): Promise<{ toolResult: CallToolResult }> { try { await page.click(args.selector); return { toolResult: { content: [{ type: "text", text: `Clicked element: ${args.selector}`, }], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `Click failed on ${args.selector}: ${(error as Error).message}`, }], isError: true, }, }; } }
- src/tools.ts:73-83 (schema)Defines the tool schema including name, description, and inputSchema requiring a 'selector' string for the CSS selector.{ name: "browser_click", description: "Click an element on the page", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to click" } }, required: ["selector"] } },
- src/executor.ts:194-195 (registration)Switch case in executeToolCall that registers and routes browser_click tool calls to the handleBrowserClick function.case "browser_click": return await handleBrowserClick(activePage!, args);