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
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text content of the element to click |
Implementation Reference
- index.ts:301-340 (handler)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, }; }
- index.ts:86-96 (schema)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",