Skip to main content
Glama

click_element

Click on webpage elements using CSS selectors to automate browser interactions for testing, debugging, and data extraction workflows.

Instructions

Clica em um elemento da página

Input Schema

NameRequiredDescriptionDefault
selectorYesSeletor CSS do elemento para clicar
waitForNavigationNoAguardar navegação após o clique

Input Schema (JSON Schema)

{ "properties": { "selector": { "description": "Seletor CSS do elemento para clicar", "type": "string" }, "waitForNavigation": { "default": false, "description": "Aguardar navegação após o clique", "type": "boolean" } }, "required": [ "selector" ], "type": "object" }

Implementation Reference

  • The core handler function that implements the click_element tool. It clicks on the specified CSS selector using Puppeteer's page.click(), optionally waiting for navigation, and returns a success message.
    export async function handleClickElement(args: unknown, currentPage: Page): Promise<ToolResponse> { const typedArgs = args as unknown as ClickElementArgs; const { selector, waitForNavigation = false } = typedArgs; if (waitForNavigation) { await Promise.all([currentPage.waitForNavigation(), currentPage.click(selector)]); } else { await currentPage.click(selector); } return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Elemento clicado: ${selector}`, }), }, ], }; }
  • TypeScript interface defining the input arguments for the click_element tool: selector (required) and waitForNavigation (optional).
    export interface ClickElementArgs { selector: string; waitForNavigation?: boolean; }
  • src/tools.ts:192-210 (registration)
    MCP tool registration entry including the name 'click_element', description, and JSON inputSchema for validation.
    { name: 'click_element', description: 'Clica em um elemento da página', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'Seletor CSS do elemento para clicar', }, waitForNavigation: { type: 'boolean', description: 'Aguardar navegação após o clique', default: false, }, }, required: ['selector'], }, },
  • src/index.ts:103-106 (registration)
    Runtime dispatch/registration in the main server handler switch statement, which initializes the browser page and calls the click_element handler.
    case 'click_element': { const currentPage = await initBrowser(); return await handleClickElement(args, currentPage); }

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/EmmanuelBarbosaMonteiro/mcp-server-browser'

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