browser_switch_to_parent_frame
Switch back to the parent frame when working with nested iframes in web automation. This allows you to navigate between iframe contexts and return to the main document structure.
Instructions
Switches to the parent iframe
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/elementTools.ts:339-357 (handler)Handler and registration for the browser_switch_to_parent_frame tool. Retrieves the WebDriver instance, instantiates ElementService, calls switchToParentFrame on it, and returns a success or error message in the expected format.server.tool('browser_switch_to_parent_frame', 'Switches to the parent iframe', async () => { try { const driver = stateManager.getDriver(); const elementService = new ElementService(driver); await elementService.switchToParentFrame(); return { content: [{ type: 'text', text: 'Switched to parent frame' }], }; } catch (e) { return { content: [ { type: 'text', text: `Error switching to parent frame: ${(e as Error).message}`, }, ], }; } });
- src/services/elementService.ts:86-88 (helper)The core helper method in ElementService that switches the WebDriver context to the parent frame.async switchToParentFrame(): Promise<void> { await this.driver.switchTo().parentFrame(); }