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
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"selector": "<selector>"
},
"name": "click_element"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | Seletor CSS do elemento para clicar | |
| waitForNavigation | No | Aguardar navegação após o clique |
Implementation Reference
- src/browserTools.ts:478-499 (handler)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}`, }), }, ], }; } - src/types.ts:75-78 (schema)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); }