browser_switch_to_window
Switch between multiple browser windows during automated testing to interact with different web pages or tabs in your test workflow.
Instructions
Switch to a different browser window
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| windowHandle | Yes | The handle of the window to switch to |
Implementation Reference
- src/tools/browserTools.ts:235-258 (registration)Registration of the 'browser_switch_to_window' tool, including inline schema and handler function that switches the browser driver to the specified window handle.'browser_switch_to_window', 'Switch to a different browser window', { windowHandle: z.string().describe('The handle of the window to switch to'), }, async ({ windowHandle }) => { try { const driver = stateManager.getDriver(); await driver.switchTo().window(windowHandle); return { content: [{ type: 'text', text: `Switched to window: ${windowHandle}` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error switching window: ${(e as Error).message}`, }, ], }; } } );
- src/tools/browserTools.ts:240-257 (handler)The handler function executes the tool logic by retrieving the current driver from stateManager and calling driver.switchTo().window(windowHandle).async ({ windowHandle }) => { try { const driver = stateManager.getDriver(); await driver.switchTo().window(windowHandle); return { content: [{ type: 'text', text: `Switched to window: ${windowHandle}` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error switching window: ${(e as Error).message}`, }, ], }; } }
- src/tools/browserTools.ts:237-239 (schema)Input schema defining 'windowHandle' as a required string parameter.{ windowHandle: z.string().describe('The handle of the window to switch to'), },