hover
Simulate hovering over any webpage element using a CSS selector, enabling interaction testing and dynamic content inspection in the PlayMCP Browser Automation Server.
Instructions
Hover over an element on the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes |
Implementation Reference
- src/controllers/playwright.ts:620-632 (handler)The main handler function that executes the hover action using Playwright's locator.hover() method on the given CSS selector.async hover(selector: string): Promise<void> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Hovering over element', { selector }); const locator = this.state.page.locator(selector); await locator.hover(); this.log('Hover complete'); } catch (error: any) { console.error('Hover error:', error); throw new BrowserError('Failed to hover over element', 'Check if the selector exists and is visible'); }
- src/server.ts:270-280 (schema)JSON schema defining the input parameters for the 'hover' tool: requires a 'selector' string.const HOVER_TOOL: Tool = { name: "hover", description: "Hover over an element on the page", inputSchema: { type: "object", properties: { selector: { type: "string" } }, required: ["selector"] } };
- src/server.ts:536-536 (registration)Registration of the HOVER_TOOL object in the tools map provided to the MCP server's capabilities.hover: HOVER_TOOL,
- src/server.ts:795-806 (registration)Dispatch logic in the 'callTool' handler that validates input and invokes the hover handler from playwrightController.case 'hover': { if (!args.selector) { return { content: [{ type: "text", text: "Selector is required" }], isError: true }; } await playwrightController.hover(args.selector as string); return { content: [{ type: "text", text: "Hover completed successfully" }] }; }