browser_switch_to_original_window
Switch back to the original browser window when working with multiple browser windows during web automation tasks.
Instructions
Switches back to the original browser window
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/browserTools.ts:260-289 (handler)The inline handler function for the 'browser_switch_to_original_window' tool. It retrieves the browser driver, gets all window handles, assumes the first one is the original, switches to it, and returns appropriate success or error messages.server.tool('browser_switch_to_original_window', 'Switches back to the original browser window', {}, async () => { try { const driver = stateManager.getDriver(); const windowHandles = await driver.getAllWindowHandles(); const originalHandle = windowHandles[0]; if (!originalHandle) { return { content: [ { type: 'text', text: `No original window handle found.`, }, ], }; } await driver.switchTo().window(originalHandle); return { content: [{ type: 'text', text: `Switched to original window` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error switching to original window: ${(e as Error).message}`, }, ], }; } });