browser_right_click
Perform right-click actions on web elements to access context menus during browser automation testing and interaction workflows.
Instructions
Perform right click (context click) on an element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | Yes | Locator strategy to find element | |
| timeout | No | Maximum time to wait for element in milliseconds | |
| value | Yes | Value for the locator strategy |
Implementation Reference
- src/tools/actionTools.ts:117-140 (registration)Registers the browser_right_click MCP tool, including description, input schema (locatorSchema), and handler function that delegates to ActionService.rightClickElementserver.tool( 'browser_right_click', 'Perform right click (context click) on an element', { ...locatorSchema }, async ({ by, value, timeout = 15000 }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.rightClickElement({ by, value, timeout }); return { content: [{ type: 'text', text: 'Right click performed' }], }; } catch (e) { return { content: [ { type: 'text', text: `Error performing right click: ${(e as Error).message}`, }, ], }; } } );
- src/services/actionService.ts:39-44 (handler)Core handler logic for right-clicking an element: locates the element and performs contextClick using Selenium WebDriver Actionsasync rightClickElement(params: LocatorParams): Promise<void> { const locator = LocatorFactory.createLocator(params.by, params.value); const element = await this.driver.wait(until.elementLocated(locator), params.timeout || 15000); const actions = this.driver.actions({ bridge: true }); await actions.contextClick(element).perform(); }
- src/types/index.ts:29-35 (schema)Zod schema for locator parameters (by, value, timeout) used in the browser_right_click tool inputexport const locatorSchema = { by: z .enum(['id', 'css', 'xpath', 'name', 'tag', 'class', 'link', 'partialLink']) .describe('Locator strategy to find element'), value: z.string().describe('Value for the locator strategy'), timeout: z.number().optional().describe('Maximum time to wait for element in milliseconds'), };
- src/tools/index.ts:11-11 (registration)Top-level registration call for action tools, which includes browser_right_clickregisterActionTools(server, stateManager);