playwright_hover
Simulate hover interactions on web elements using a CSS selector with browser automation. Enables precise testing, scraping, and debugging within real browser environments.
Instructions
Hover an element on the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for element to hover |
Implementation Reference
- src/tools/browser/interaction.ts:123-134 (handler)The HoverTool class containing the execute method that implements the core logic: waits for selector and performs page.hover using Playwright.export class HoverTool extends BrowserToolBase { /** * Execute the hover tool */ async execute(args: any, context: ToolContext): Promise<ToolResponse> { return this.safeExecute(context, async (page) => { await page.waitForSelector(args.selector); await page.hover(args.selector); return createSuccessResponse(`Hovered ${args.selector}`); }); } }
- src/tools.ts:173-183 (schema)MCP tool definition including name, description, and input schema requiring a 'selector' parameter.{ name: "playwright_hover", description: "Hover an element on the page", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to hover" }, }, required: ["selector"], }, },
- src/toolHandler.ts:499-500 (registration)Switch case in handleToolCall that registers and dispatches to the hoverTool.execute handler.case "playwright_hover": return await hoverTool.execute(args, context);
- src/tools/index.ts:6-20 (registration)BROWSER_TOOLS constant listing playwright_hover as a browser-requiring tool for conditional initialization.export const BROWSER_TOOLS = [ "playwright_navigate", "playwright_screenshot", "playwright_click", "playwright_iframe_click", "playwright_iframe_fill", "playwright_fill", "playwright_select", "playwright_hover", "playwright_evaluate", "playwright_console_logs", "playwright_close", "playwright_get_visible_text", "playwright_get_visible_html" ];
- src/tools/codegen/generator.ts:79-80 (helper)Codegen generator case that converts playwright_hover action to Playwright hover code snippet.case 'playwright_hover': return this.generateHoverStep(parameters);