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
dont force-close about:blank tabs
Nick Sweeting41ba515358d0
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex df72b97bf..451b39880 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -2227,7 +2227,7 @@ class BrowserSession(BaseModel):# --- Page navigation ---@observe_debug()- @retry(retries=0, timeout=30, wait=1)+ @retry(retries=0, timeout=30, wait=1, semaphore_timeout=10, semaphore_limit=1, semaphore_scope='self', semaphore_lax=True)@require_healthy_browser(usable_page=False, reopen_page=False)async def navigate(self, url: str = 'about:blank', new_tab: bool = False, timeout_ms: int | None = None) -> Page:"""@@ -3496,7 +3496,7 @@ class BrowserSession(BaseModel):# (could close too many pages by accident if we have a few different tabs on the same URL)# Sometimes playwright doesn't immediately remove force-closed pages from the listfor page in self.browser_context.pages[:]: # Use slice to avoid modifying list during iteration- if page.url == current_url and not page.is_closed():+ if page.url == current_url and not page.is_closed() and not is_new_tab_page(page.url):try:# Try to close it via playwright as wellawait page.close()