playwright_hover
Simulate mouse hover interactions on web elements using CSS selectors for testing or automation workflows.
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:130-141 (handler)The HoverTool.execute method provides the core implementation of the playwright_hover tool, waiting for the selector and performing a hover action using Playwright's page.hover.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:184-193 (schema)JSON schema defining the input parameters for the playwright_hover tool, requiring a CSS selector.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:600-601 (registration)Registration in the main tool handler switch statement that dispatches playwright_hover calls to the HoverTool instance.case "playwright_hover": return await hoverTool.execute(args, context);
- src/toolHandler.ts:397-397 (registration)Initialization of the global HoverTool instance in toolHandler.ts.if (!hoverTool) hoverTool = new HoverTool(server);
- src/tools/codegen/generator.ts:79-80 (helper)Codegen helper that generates Playwright test code for the hover action.case "playwright_hover": return this.generateHoverStep(parameters);