Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
allow agent to attempt to use crashed pages
Nick Sweeting317b2d1fe359
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 12bae2afc..cfc42707d 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -2269,7 +2269,7 @@ class BrowserSession(BaseModel):self.logger.debug(f'✅ Page is responsive despite navigation timeout on: {_log_pretty_url(current_url)})')else:self.logger.error(- f'❌ Page is unresponsive after navigation timeout on: {_log_pretty_url(current_url)} uh oh!'+ f'❌ Page is unresponsive after navigation timeout on: {_log_pretty_url(current_url)} uh oh! subsequent operations may fail on this page...')raise Exception(f'Page JS engine is unresponsive after navigation / loading timeout on: {_log_pretty_url(current_url)}). Agent cannot proceed with this page because its JS event loop is unresponsive.'@@ -2278,11 +2278,13 @@ class BrowserSession(BaseModel):# Navigation completed, check if it succeededawait nav_task # This will raise if navigation failedexcept Exception as e:- # if 'timeout' in str(e).lower():- # self.logger.warning(- # f"⚠️ Loading {_log_pretty_url(normalized_url)} didn't finish after timeout, continuing anyway..."- # )- raise+ if 'timeout' in str(e).lower():+ # self.logger.warning(+ # f"⚠️ Loading {_log_pretty_url(normalized_url)} didn't finish and further operations may fail on this page..."+ # )+ pass # allow agent to attempt to continue without raising hard error, it can use tools to work around it+ else:+ raise# Show DVD animation on new tab pages if no URL specifiedif new_tab and is_new_tab_page(page.url):diff --git a/tests/ci/test_browser_session_crashed_page_recovery.py b/tests/ci/test_browser_session_crashed_page_recovery.pyindex 717100050..4d48d5ae0 100644--- a/tests/ci/test_browser_session_crashed_page_recovery.py+++ b/tests/ci/test_browser_session_crashed_page_recovery.py@@ -236,7 +236,11 @@ class TestBrowserSessionRecovery:# Navigate to the permanently blocking pageblocking_url = httpserver.url_for('/permanent-block')print(f'1️⃣ Navigating to blocking page: {blocking_url}')- await browser_session.navigate(blocking_url)+ try:+ await browser_session.navigate(blocking_url)+ except Exception as e:+ # Expected - the page is unresponsive+ print(f' Navigation raised expected error: {type(e).__name__}')await asyncio.sleep(0.5) # Let blocking script start# We need to patch goto on any new pages created during recovery