Skip to content

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

Fix default disable_security

Magnus Müller723a988a08cf
diff --git a/browser_use/browser/browser.py b/browser_use/browser/browser.py
index 711e19a99..1b8a41bd6 100644
--- a/browser_use/browser/browser.py
+++ b/browser_use/browser/browser.py
@@ -27,7 +27,7 @@ class BrowserConfig:
headless: True
Whether to run browser in headless mode
- disable_security: False
+ disable_security: True
Disable browser security features
extra_chromium_args: []
@@ -82,9 +82,7 @@ class Browser:
'--disable-features=IsolateOrigins,site-per-process',
]
- async def new_context(
- self, config: BrowserContextConfig = BrowserContextConfig()
- ) -> BrowserContext:
+ async def new_context(self, config: BrowserContextConfig = BrowserContextConfig()) -> BrowserContext:
"""Create a browser context"""
return BrowserContext(config=config, browser=self)
@@ -147,11 +145,12 @@ class Browser:
[
self.config.chrome_instance_path,
'--remote-debugging-port=9222',
- ] + self.config.extra_chromium_args,
+ ]
+ + self.config.extra_chromium_args,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
-
+
# Attempt to connect again after starting a new instance
for _ in range(10):
try:
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index b730bc218..18899914a 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -54,7 +54,7 @@ class BrowserContextConfig:
cookies_file: None
Path to cookies file for persistence
- disable_security: False
+ disable_security: True
Disable browser security features
minimum_wait_page_load_time: 0.5
@@ -114,7 +114,7 @@ class BrowserContextConfig:
maximum_wait_page_load_time: float = 5
wait_between_actions: float = 1
- disable_security: bool = False
+ disable_security: bool = True
browser_window_size: BrowserContextWindowSize = field(default_factory=lambda: {'width': 1280, 'height': 1100})
no_viewport: Optional[bool] = None
@@ -231,7 +231,7 @@ class BrowserContext:
def _add_new_page_listener(self, context: PlaywrightBrowserContext):
async def on_page(page: Page):
if self.browser.config.cdp_url:
- await page.reload() # Reload the page to avoid timeout errors
+ await page.reload() # Reload the page to avoid timeout errors
await page.wait_for_load_state()
logger.debug(f'New page opened: {page.url}')
if self.session is not None:
@@ -957,7 +957,7 @@ class BrowserContext:
else:
await element_handle.fill(text)
except Exception:
- logger.debug(f'Could not type text into element. Trying to click and type.')
+ logger.debug('Could not type text into element. Trying to click and type.')
await element_handle.click()
await element_handle.type(text, delay=5)
@@ -1176,7 +1176,6 @@ class BrowserContext:
tabs=[],
)
-
async def _get_unique_filename(self, directory, filename):
"""Generate a unique filename by appending (1), (2), etc., if a file already exists."""
base, ext = os.path.splitext(filename)
@@ -1186,4 +1185,3 @@ class BrowserContext:
new_filename = f'{base} ({counter}){ext}'
counter += 1
return new_filename
-