hover
Hover over web page elements to trigger interactive features, reveal hidden content, or prepare for further actions during browser automation.
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-633 (handler)Core handler function in PlaywrightController that locates the element using the provided selector and performs the hover action using Playwright's locator.hover() method, with error handling and logging.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)Defines the Tool object for 'hover' including name, description, and inputSchema requiring a 'selector' string parameter.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)Registers the HOVER_TOOL in the 'tools' object which is provided to the MCP Server capabilities.hover: HOVER_TOOL,
- src/server.ts:795-806 (handler)MCP request handler in the 'callTool' switch statement that validates the selector argument, calls the PlaywrightController.hover method, and returns success response.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" }] }; }