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
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text content of the element to click |
Implementation Reference
- index.ts:301-340 (handler)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"], }, },
- index.ts:26-26 (helper)Enum constant in ToolName that maps BrowserClickText to the string tool name 'browser_click_text'.BrowserClickText = "browser_click_text",