Skip to content

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

fix chrome connecting to extension context by accident

Nick Sweeting554c51859e6a
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index cb202a016..e81e2a38e 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -283,7 +283,12 @@ class BrowserContext:
# If no target ID or couldn't find it, use existing page or create new
if not active_page:
- if pages and pages[0].url:
+ if (
+ pages
+ and pages[0].url
+ and not pages[0].url.startswith('chrome://')
+ and not pages[0].url.startswith('chrome-extension://')
+ ):
active_page = pages[0]
logger.debug('Using existing page: %s', active_page.url)
else:
@@ -616,8 +621,8 @@ class BrowserContext:
parsed_url = urlparse(url)
domain = parsed_url.netloc.lower()
- # Special case: Allow 'about:blank' explicitly
- if url == "about:blank":
+ # Special case: Allow 'about:blank' explicitly
+ if url == 'about:blank':
return True
# Remove port number if present