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
remove custom chrome flags now that we use patchright
Nick Sweetingc693e5b6a835
diff --git a/browser_use/browser/chrome.py b/browser_use/browser/chrome.pyindex 7292e2316..2aebcd2e1 100644--- a/browser_use/browser/chrome.py+++ b/browser_use/browser/chrome.py@@ -1,5 +1,5 @@CHROME_DEFAULT_USER_AGENT = (- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.3')CHROME_EXTENSIONS = {} # coming in a separate PRCHROME_EXTENSIONS_PATH = 'chrome_extensions'@@ -30,8 +30,8 @@ CHROME_DISABLED_COMPONENTS = [CHROME_HEADLESS_ARGS = ['--headless=new',- '--test-type',- '--test-type=gpu', # https://github.com/puppeteer/puppeteer/issues/10516+ # '--test-type',+ # '--test-type=gpu', # https://github.com/puppeteer/puppeteer/issues/10516# '--enable-automation', # <- DONT USE THIS, it makes you easily detectable / blocked by cloudflare]@@ -63,18 +63,18 @@ CHROME_DISABLE_SECURITY_ARGS = [# flags to make chrome behave more deterministically across different OS'sCHROME_DETERMINISTIC_RENDERING_ARGS = [- '--deterministic-mode',- '--js-flags=--random-seed=1157259159', # make all JS random numbers deterministic by providing a seed- '--force-device-scale-factor=1',+ # '--deterministic-mode',+ # '--js-flags=--random-seed=1157259159', # make all JS random numbers deterministic by providing a seed+ # '--force-device-scale-factor=1','--hide-scrollbars', # hide scrollbars because otherwise they show up in screenshots# GPU, canvas, text, and pdf rendering config# chrome://gpu- '--enable-webgl', # enable web-gl graphics support- '--font-render-hinting=none', # make rendering more deterministic by ignoring OS font hints, may also need css override, try: * {text-rendering: geometricprecision !important; -webkit-font-smoothing: antialiased;}- '--force-color-profile=srgb', # make rendering more deterministic by using consistent color profile, if browser looks weird, try: generic-rgb- '--disable-partial-raster', # make rendering more deterministic (TODO: verify if still needed)- '--disable-skia-runtime-opts', # make rendering more deterministic by avoiding Skia hot path runtime optimizations- '--disable-2d-canvas-clip-aa', # make rendering more deterministic by disabling antialiasing on 2d canvas clips+ # '--enable-webgl', # enable web-gl graphics support+ # '--font-render-hinting=none', # make rendering more deterministic by ignoring OS font hints, may also need css override, try: * {text-rendering: geometricprecision !important; -webkit-font-smoothing: antialiased;}+ # '--force-color-profile=srgb', # make rendering more deterministic by using consistent color profile, if browser looks weird, try: generic-rgb+ # '--disable-partial-raster', # make rendering more deterministic (TODO: verify if still needed)+ # '--disable-skia-runtime-opts', # make rendering more deterministic by avoiding Skia hot path runtime optimizations+ # '--disable-2d-canvas-clip-aa', # make rendering more deterministic by disabling antialiasing on 2d canvas clips# '--disable-gpu', # falls back to more consistent software renderer across all OS's, especially helps linux text rendering look less weird# // '--use-gl=swiftshader', <- DO NOT USE, breaks M1 ARM64. it makes rendering more deterministic by using simpler CPU renderer instead of OS GPU renderer bug: https://groups.google.com/a/chromium.org/g/chromium-dev/c/8eR2GctzGuw# // '--disable-software-rasterizer', <- DO NOT USE, harmless, used in tandem with --disable-gpu@@ -83,15 +83,15 @@ CHROME_DETERMINISTIC_RENDERING_ARGS = [# // '--blink-settings=imagesEnabled=false', <- DO NOT USE, disables images entirely (only sometimes useful to speed up loading)# Process management & performance tuning# chrome://process-internals- '--disable-lazy-loading', # make rendering more deterministic by loading all content up-front instead of on-focus- '--disable-renderer-backgrounding', # dont throttle tab rendering based on focus/visibility- '--disable-background-networking', # dont throttle tab networking based on focus/visibility- '--disable-background-timer-throttling', # dont throttle tab timers based on focus/visibility- '--disable-backgrounding-occluded-windows', # dont throttle tab window based on focus/visibility- '--disable-ipc-flooding-protection', # dont throttle ipc traffic or accessing big request/response/buffer/etc. objects will fail- '--disable-extensions-http-throttling', # dont throttle http traffic based on runtime heuristics- '--disable-field-trial-config', # disable shared field trial state between browser processes- '--disable-back-forward-cache', # disable browsing navigation cache+ # '--disable-lazy-loading', # make rendering more deterministic by loading all content up-front instead of on-focus+ # '--disable-renderer-backgrounding', # dont throttle tab rendering based on focus/visibility+ # '--disable-background-networking', # dont throttle tab networking based on focus/visibility+ # '--disable-background-timer-throttling', # dont throttle tab timers based on focus/visibility+ # '--disable-backgrounding-occluded-windows', # dont throttle tab window based on focus/visibility+ # '--disable-ipc-flooding-protection', # dont throttle ipc traffic or accessing big request/response/buffer/etc. objects will fail+ # '--disable-extensions-http-throttling', # dont throttle http traffic based on runtime heuristics+ # '--disable-field-trial-config', # disable shared field trial state between browser processes+ # '--disable-back-forward-cache', # disable browsing navigation cache]@@ -110,7 +110,7 @@ CHROME_ARGS = [# f'--allowlisted-extension-id={",".join(CHROME_EXTENSIONS.keys())}','--allow-legacy-extension-manifests','--allow-pre-commit-input', # allow JS mutations before page rendering is complete- '--disable-blink-features=AutomationControlled', # hide the signatures that announce browser is being remote-controlled+ # '--disable-blink-features=AutomationControlled', # hide the signatures that announce browser is being remote-controlled# f'--proxy-server=https://43.159.28.126:2334:u7ce652b7568805c4-zone-custom-region-us-session-szGWq3FRU-sessTime-60:u7ce652b7568805c4', # send all network traffic through a proxy https://2captcha.com/proxy# f'--proxy-bypass-list=127.0.0.1',# Browser window and viewport setup@@ -129,7 +129,7 @@ CHROME_ARGS = ['--log-level=2', # 1=DEBUG 2=WARNING 3=ERROR'--enable-logging=stderr',# '--remote-debugging-address=127.0.0.1', <- never expose to non-localhost, would allow attacker to drive your browser from any machine- '--enable-experimental-extension-apis', # add support for tab groups+ # '--enable-experimental-extension-apis', # add support for tab groups'--disable-focus-on-load', # prevent browser from hijacking focus'--disable-window-activation',# '--in-process-gpu', <- DONT USE THIS, makes headful startup time ~5-10s slower (tested v121 Google Chrome.app on macOS)@@ -148,7 +148,6 @@ CHROME_ARGS = ['--no-first-run','--no-default-browser-check','--no-startup-window',- '--disable-default-apps','--ash-no-nudges','--disable-infobars','--disable-search-engine-choice-screen',@@ -158,7 +157,6 @@ CHROME_ARGS = ['--suppress-message-center-popups','--disable-client-side-phishing-detection','--disable-domain-reliability',- '--disable-component-update','--disable-datasaver-prompt','--disable-hang-monitor','--disable-session-crashed-bubble',@@ -166,12 +164,11 @@ CHROME_ARGS = ['--disable-speech-api','--disable-print-preview','--safebrowsing-disable-auto-update',- '--deny-permission-prompts',+ # '--deny-permission-prompts','--disable-external-intent-requests','--disable-notifications','--disable-desktop-notifications','--noerrdialogs',- '--disable-popup-blocking','--disable-prompt-on-repost','--silent-debugger-extension-api','--block-new-web-contents',@@ -179,6 +176,6 @@ CHROME_ARGS = ['--disable-breakpad',# other feature flags# chrome://flags chrome://components- f'--disable-features={",".join(CHROME_DISABLED_COMPONENTS)}',- '--enable-features=NetworkService',+ # f'--disable-features={",".join(CHROME_DISABLED_COMPONENTS)}',+ # '--enable-features=NetworkService',]