Skip to main content
Glama

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
NameRequiredDescriptionDefault
windowHandleYesThe handle of the window to switch to

Implementation Reference

  • 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}`, }, ], }; } } );
  • 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}`, }, ], }; } }
  • Input schema defining 'windowHandle' as a required string parameter.
    { windowHandle: z.string().describe('The handle of the window to switch to'), },

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