browser_key_press
Simulate keyboard key presses during web automation to interact with forms, navigate pages, or trigger browser actions using Selenium WebDriver.
Instructions
Press a key on the keyboard
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Key to press (e.g., 'Enter', 'Tab', 'a', etc.) |
Implementation Reference
- src/tools/actionTools.ts:203-228 (registration)Registers the 'browser_key_press' MCP tool with server.tool(), including input schema for 'key' parameter and the handler function that retrieves the WebDriver, instantiates ActionService, calls pressKey(key), and returns success/error messages.server.tool( 'browser_key_press', 'Press a key on the keyboard', { key: z.string().describe("Key to press (e.g., 'Enter', 'Tab', 'a', etc.)"), }, async ({ key }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.pressKey(key); return { content: [{ type: 'text', text: `Key '${key}' pressed` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error pressing key: ${(e as Error).message}`, }, ], }; } } );
- src/services/actionService.ts:60-63 (handler)Implements the core key press functionality in ActionService using Selenium WebDriver's ActionSequence: keyDown(key) followed by keyUp(key).async pressKey(key: string): Promise<void> { const actions = this.driver.actions({ bridge: true }); await actions.keyDown(key).keyUp(key).perform(); }
- src/tools/actionTools.ts:206-208 (schema)Zod schema defining the input parameter 'key' as a string for the browser_key_press tool.{ key: z.string().describe("Key to press (e.g., 'Enter', 'Tab', 'a', etc.)"), },