hover
Simulate mouse hover interactions on web elements using CSS selectors for browser automation and testing workflows.
Instructions
Hover over an element on the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for the element to hover |
Implementation Reference
- index.js:722-748 (handler)The handler function for the 'hover' tool. It ensures Chromium is running, queries the DOM for the element using the provided CSS selector, calculates the center position of the element, and dispatches a 'mouseMoved' input event to simulate hovering.async hover(selector) { await this.ensureChromium(); const doc = await this.sendCDPCommand('DOM.getDocument'); const element = await this.sendCDPCommand('DOM.querySelector', { nodeId: doc.root.nodeId, selector }); if (!element.nodeId) { throw new Error(`Element not found: ${selector}`); } const box = await this.sendCDPCommand('DOM.getBoxModel', { nodeId: element.nodeId }); const quad = box.model.content; const x = (quad[0] + quad[4]) / 2; const y = (quad[1] + quad[5]) / 2; await this.sendCDPCommand('Input.dispatchMouseEvent', { type: 'mouseMoved', x, y }); return { content: [{ type: 'text', text: `Hovered over element: ${selector}` }], }; }
- index.js:202-211 (schema)Input schema definition for the 'hover' tool, specifying that it requires a 'selector' property of type string.inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to hover', }, }, required: ['selector'], },
- index.js:199-212 (registration)Registration of the 'hover' tool in the ListTools response, including name, description, and input schema.{ name: 'hover', description: 'Hover over an element on the page', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to hover', }, }, required: ['selector'], }, },
- index.js:363-364 (registration)Dispatch/registration of the 'hover' tool handler in the CallToolRequestSchema switch statement.case 'hover': return await this.hover(args.selector);