Skip to content

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

fix(headless): support headless for real chrome

lanudry2d9c3b7a846f7
diff --git a/browser_use/browser/browser.py b/browser_use/browser/browser.py
index 9278ac34c..85422bc74 100644
--- a/browser_use/browser/browser.py
+++ b/browser_use/browser/browser.py
@@ -146,11 +146,14 @@ class Browser:
logger.debug('No existing Chrome instance found, starting a new one')
# Start a new Chrome instance
- subprocess.Popen(
- [
+ args = [
self.config.chrome_instance_path,
'--remote-debugging-port=9222',
]
+ if self.config.headless:
+ args.append('--headless')
+ subprocess.Popen(
+ args
+ self.config.extra_chromium_args,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,