browser_hover_text
Simulate hovering over a web page element using its text content for precise interaction during vulnerability testing, enhancing web application security assessments.
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)Handler implementation for the browser_hover_text tool. Hovers over the page element matching the provided text using Playwright's getByText().hover(), with fallback for strict mode violations by targeting the first matching element.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:147-153 (schema)Input schema definition for the browser_hover_text tool, specifying a required 'text' string parameter.inputSchema: { type: "object", properties: { text: { type: "string", description: "Text content of the element to hover" }, }, required: ["text"], },
- index.ts:144-154 (registration)Registration of the browser_hover_text tool in the TOOLS array used by the MCP server for listing available tools.{ 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:31-31 (helper)Enum constant definition mapping BrowserHoverText to the tool name string 'browser_hover_text'.BrowserHoverText = "browser_hover_text",