Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

invalidate page state when child iframes navigate

Nick Sweeting36cfda581a30
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index 0fb40ae6f..bb965b164 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -760,8 +760,10 @@ class BrowserContext:
# Check if current page is still valid, if not switch to another available page
try:
page = await self.get_current_page()
- # Test if page is still accessible
+ # Test if page and its iframes are still accessible
await page.evaluate('1')
+ # for frame in page.frames:
+ # await frame.evaluate('1')
except Exception as e:
logger.debug(f'Current page is no longer accessible: {str(e)}')
# Get all available pages