browser_hover
Hover over elements on web pages to trigger interactive behaviors like tooltips, dropdowns, or menu expansions for testing or automation purposes.
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:122-131 (handler)The handler function for the 'browser_hover' tool. It resolves the element locator from the input parameters, adds the corresponding Playwright hover code to the response, sets the snapshot inclusion flag, and executes the hover action while waiting for completion.handle: async (tab, params, response) => { response.setIncludeSnapshot(); const locator = await tab.refLocator(params); response.addCode(`await page.${await generateLocator(locator)}.hover();`); await tab.waitForCompletion(async () => { await locator.hover(); }); },
- src/tools/snapshot.ts:114-120 (schema)Schema definition for the 'browser_hover' tool, specifying the name, title, description, input schema (using shared elementSchema), and readOnly type.schema: { name: 'browser_hover', title: 'Hover mouse', description: 'Hover over element on page', inputSchema: elementSchema, type: 'readOnly', },
- src/tools/snapshot.ts:112-132 (registration)The complete definition and registration of the 'browser_hover' tool using defineTabTool, which includes the schema and handler.const hover = defineTabTool({ capability: 'core', schema: { name: 'browser_hover', title: 'Hover mouse', description: 'Hover over element on page', inputSchema: elementSchema, type: 'readOnly', }, handle: async (tab, params, response) => { response.setIncludeSnapshot(); const locator = await tab.refLocator(params); response.addCode(`await page.${await generateLocator(locator)}.hover();`); await tab.waitForCompletion(async () => { await locator.hover(); }); }, });
- src/tools/snapshot.ts:39-42 (helper)Shared Zod schema for element input parameters (element description and ref), used as inputSchema for browser_hover and other tools.export 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:160-166 (registration)Export of the tool modules, including the browser_hover tool (as 'hover'), for higher-level registration.export default [ snapshot, click, drag, hover, selectOption, ];