browser_hover
Simulate hovering over a specific element on a web page using structured accessibility snapshots, enabling precise interaction without screenshots or vision models.
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-144 (handler)Handler function that executes the browser_hover tool. It retrieves the locator for the specified element from the page snapshot and performs a hover action, generating corresponding code and an action callback.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:121-127 (schema)Schema definition for the browser_hover tool, specifying name, title, description, input schema (requiring element description and ref), and type as readOnly.schema: { name: 'browser_hover', title: 'Hover mouse', description: 'Hover over element on page', inputSchema: elementSchema, type: 'readOnly', },
- src/tools/snapshot.ts:119-145 (registration)The complete tool definition and registration using defineTool, which includes schema and handler for browser_hover.const hover = defineTool({ capability: 'core', schema: { name: 'browser_hover', title: 'Hover mouse', description: 'Hover over element on page', inputSchema: elementSchema, type: 'readOnly', }, 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 (helper)Shared Zod schema for element parameters used in browser_hover inputSchema.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'), });