browser_hover_text
Hover over webpage elements by text content to identify interactive components during security testing for vulnerability detection.
Instructions
Hover 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 hover |
Implementation Reference
- index.ts:506-545 (handler)The main handler logic for the 'browser_hover_text' tool. It uses Playwright's page.getByText to locate an element by text and calls hover() on it, with comprehensive error handling including retry for strict mode violations.case ToolName.BrowserHoverText: try { await page.getByText(args.text).hover(); return { content: [{ type: "text", text: `Hovered 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().hover(); return { content: [{ type: "text", text: `Hovered element with text: ${args.text}`, }], isError: false, }; } catch (error) { return { content: [{ type: "text", text: `Failed (twice) to hover element with text ${args.text}: ${(error as Error).message}`, }], isError: true, }; } } return { content: [{ type: "text", text: `Failed to hover element with text ${args.text}: ${(error as Error).message}`, }], isError: true, }; }
- index.ts:144-154 (registration)Registration of the 'browser_hover_text' tool in the TOOLS array, including its name (ToolName.BrowserHoverText), description, and input schema definition. This array is used by the ListToolsRequestSchema handler.{ name: ToolName.BrowserHoverText, description: "Hover an element on the page by its text content", inputSchema: { type: "object", properties: { text: { type: "string", description: "Text content of the element to hover" }, }, required: ["text"], }, },
- index.ts:147-153 (schema)Input schema for the 'browser_hover_text' tool, defining a required 'text' string parameter.inputSchema: { type: "object", properties: { text: { type: "string", description: "Text content of the element to hover" }, }, required: ["text"], },
- index.ts:31-31 (helper)Enum constant defining the tool name string 'browser_hover_text' used throughout the code.BrowserHoverText = "browser_hover_text",