browser_hover
Hover over web page elements to trigger interactive features like dropdown menus, tooltips, or hover effects during browser automation with Playwright MCP.
Instructions
Hover over element on page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| element | Yes | Human-readable element description used to obtain permission to interact with the element | |
| ref | Yes | Exact target element reference from the page snapshot |
Implementation Reference
- src/tools/snapshot.ts:129-145 (handler)The core handler function that executes the browser_hover tool. It derives a Playwright locator from the page snapshot using the provided ref and element description, then performs a hover action via locator.hover(). It also generates equivalent code snippet for the code execution mode.handle: async (context, params) => { const snapshot = context.currentTabOrDie().snapshotOrDie(); const locator = snapshot.refLocator(params); const code = [ `// Hover over ${params.element}`, `await page.${await generateLocator(locator)}.hover();` ]; return { code, action: () => locator.hover(), captureSnapshot: true, waitForNetwork: true, }; }, });
- src/tools/snapshot.ts:44-47 (schema)Zod input schema definition for elements used in browser_hover (and other interaction tools). Requires 'element' (human-readable description) and 'ref' (exact reference from page snapshot).const elementSchema = z.object({ element: z.string().describe('Human-readable element description used to obtain permission to interact with the element'), ref: z.string().describe('Exact target element reference from the page snapshot'), });
- src/tools/snapshot.ts:121-127 (schema)Tool schema for browser_hover, defining name, title, description, inputSchema (references elementSchema), and readOnly type.schema: { name: 'browser_hover', title: 'Hover mouse', description: 'Hover over element on page', inputSchema: elementSchema, type: 'readOnly', },
- src/tools.ts:26-26 (registration)Imports the snapshot.js module which exports an array of tools including browser_hover.import snapshot from './tools/snapshot.js';
- src/tools.ts:46-46 (registration)Registers browser_hover by spreading the snapshot tools array into the main snapshotTools export....snapshot,