browser_switch_to_default_content
Return to the main browser window content after interacting with frames or iframes during web automation testing.
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 for the 'browser_switch_to_default_content' tool, which creates an ElementService instance and calls switchToDefaultContent() on it, handling errors and returning success/error messages.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 that switches the WebDriver context back to the default content.async switchToDefaultContent(): Promise<void> { await this.driver.switchTo().defaultContent(); }
- src/tools/elementTools.ts:319-337 (registration)Registration of the tool using server.tool() within the registerElementTools 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}`, }, ], }; } });