Skip to main content
Glama

browser_click_text

Automate clicking web elements by their text content for penetration testing with MCP Server Pentest, enabling efficient vulnerability detection in web applications.

Instructions

Click an element on the page by its text content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText content of the element to click

Implementation Reference

  • Implementation of the browser_click_text tool handler. Locates an element by text using page.getByText and clicks it, with fallback for strict mode violations by clicking the first matching element.
    case ToolName.BrowserClickText: try { await page.getByText(args.text).click(); return { content: [{ type: "text", text: `Clicked element with text: ${args.text}`, }], isError: false, }; } catch (error) { if((error as Error).message.includes("strict mode violation")) { console.log("Strict mode violation, retrying on first element..."); try { await page.getByText(args.text).first().click(); return { content: [{ type: "text", text: `Clicked element with text: ${args.text}`, }], isError: false, }; } catch (error) { return { content: [{ type: "text", text: `Failed (twice) to click element with text ${args.text}: ${(error as Error).message}`, }], isError: true, }; } } return { content: [{ type: "text", text: `Failed to click element with text ${args.text}: ${(error as Error).message}`, }], isError: true, }; }
  • index.ts:86-96 (registration)
    Registration of the browser_click_text tool in the TOOLS array, including its name (ToolName.BrowserClickText), description, and input schema requiring a 'text' parameter.
    { name: ToolName.BrowserClickText, description: "Click an element on the page by its text content", inputSchema: { type: "object", properties: { text: { type: "string", description: "Text content of the element to click" }, }, required: ["text"], }, },
  • Enum constant in ToolName that maps BrowserClickText to the string tool name 'browser_click_text'.
    BrowserClickText = "browser_click_text",

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/9olidity/MCP-Server-Pentest'

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