Skip to main content
Glama

browser_click_text

Click webpage elements by text content during security testing. This tool automates browser interactions for penetration testing of 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

  • Handler implementation for the 'browser_click_text' tool. Locates an element by text content using Playwright's page.getByText() and clicks it, with comprehensive error handling including retry for strict mode violations.
    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, }; }
  • Input schema and metadata for the 'browser_click_text' tool, defining a required 'text' parameter of type string.
    { 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"], }, },
  • index.ts:26-26 (registration)
    Enum registration of the tool name 'browser_click_text' as ToolName.BrowserClickText, used throughout the codebase for tool identification.
    BrowserClickText = "browser_click_text",

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