browser_hover_text
Hover over web page elements using text content to trigger interactive features or reveal hidden information during browser automation with Playwright.
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:480-519 (handler)The main handler logic for the 'browser_hover_text' tool. It uses Playwright to hover over an element matching the provided text, includes try-catch error handling, and retries on the first matching element if strict mode violation occurs.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:130-140 (schema)Schema definition for the 'browser_hover_text' tool, including input schema requiring a 'text' string parameter.{ 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:640-642 (registration)Registration of all tools, including 'browser_hover_text', via the TOOLS array in the ListToolsRequestSchema handler.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS, }));
- index.ts:22-33 (helper)ToolName enum defining the string constant for 'browser_hover_text' tool.enum ToolName { BrowserNavigate = "browser_navigate", BrowserScreenshot = "browser_screenshot", BrowserClick = "browser_click", BrowserClickText = "browser_click_text", BrowserFill = "browser_fill", BrowserSelect = "browser_select", BrowserSelectText = "browser_select_text", BrowserHover = "browser_hover", BrowserHoverText = "browser_hover_text", BrowserEvaluate = "browser_evaluate" }