browser_switch_to_default_content
Return to the main browser window from frames or iframes during web automation with Selenium WebDriver.
Instructions
Switches to the default content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/elementTools.ts:319-337 (handler)The inline handler function registered for the 'browser_switch_to_default_content' tool. It retrieves the WebDriver from stateManager, instantiates ElementService, calls switchToDefaultContent(), and returns a success or error message in MCP content format.server.tool('browser_switch_to_default_content', 'Switches to the default content', async () => { try { const driver = stateManager.getDriver(); const elementService = new ElementService(driver); await elementService.switchToDefaultContent(); return { content: [{ type: 'text', text: 'Switched to default content' }], }; } catch (e) { return { content: [ { type: 'text', text: `Error switching to default content: ${(e as Error).message}`, }, ], }; } });
- src/services/elementService.ts:82-84 (helper)The core helper method in ElementService class that executes the browser switch to default content using Selenium WebDriver's switchTo().defaultContent().async switchToDefaultContent(): Promise<void> { await this.driver.switchTo().defaultContent(); }
- src/tools/elementTools.ts:319-337 (registration)Registration of the 'browser_switch_to_default_content' tool using server.tool() with description and inline handler function.server.tool('browser_switch_to_default_content', 'Switches to the default content', async () => { try { const driver = stateManager.getDriver(); const elementService = new ElementService(driver); await elementService.switchToDefaultContent(); return { content: [{ type: 'text', text: 'Switched to default content' }], }; } catch (e) { return { content: [ { type: 'text', text: `Error switching to default content: ${(e as Error).message}`, }, ], }; } });