Skip to content

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

ignore nav during nav

Nick Sweetingc0b139e8e9cf
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 35ed96aed..16dc50a03 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -1602,7 +1602,11 @@ class BrowserSession(BaseModel):
if is_new_tab_page(page.url):
# Navigate to about:blank if we're on chrome://new-tab-page to avoid security restrictions
if page.url.startswith('chrome://new-tab-page'):
- await page.goto('about:blank')
+ try:
+ # can raise exception if nav is interrupted by another agent nav or human, harmless but annoying
+ await page.goto('about:blank', wait_until='domcontentloaded', timeout=1000)
+ except Exception:
+ pass
await self._show_dvd_screensaver_loading_animation(page)
page = page or (await self.browser_context.new_page())