Skip to main content
Glama

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
NameRequiredDescriptionDefault
selectorYesCSS selector for element to click

Implementation Reference

  • 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, }, }; } }
  • 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"] } },
  • Switch case in executeToolCall that registers and routes browser_click tool calls to the handleBrowserClick function.
    case "browser_click": return await handleBrowserClick(activePage!, args);

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/imprvhub/mcp-browser-agent'

If you have feedback or need assistance with the MCP directory API, please join our Discord server