Skip to main content
Glama

browser_switch_to_original_window

Switch back to the original browser window after working with multiple windows or tabs during web automation tasks.

Instructions

Switches back to the original browser window

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Inline handler function that switches the browser context back to the original (first) window handle by retrieving all handles and selecting index 0.
    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}`, }, ], }; } });
  • Registers the 'browser_switch_to_original_window' tool using server.tool with no input parameters.
    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}`, }, ], }; } });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pshivapr/selenium-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server