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
Add browser settings
magmueller223e22408153
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.pyindex a16d7906d..90e57f1da 100644--- a/browser_use/browser/context.py+++ b/browser_use/browser/context.py@@ -72,6 +72,7 @@ class BrowserContextConfig:no_viewport: FalseDisable viewport+save_recording_path: NonePath to save video recordingsdiff --git a/docs/customize/agent-settings.mdx b/docs/customize/agent-settings.mdxindex c2ca6bd7c..7faeb9ff3 100644--- a/docs/customize/agent-settings.mdx+++ b/docs/customize/agent-settings.mdx@@ -182,11 +182,3 @@ agent = Agent()```-## Rerunning the Agent without LLM----## Viewport extension--## Visable elements-diff --git a/docs/customize/browser-settings.mdx b/docs/customize/browser-settings.mdxindex 95f8741d8..aca4ac6d4 100644--- a/docs/customize/browser-settings.mdx+++ b/docs/customize/browser-settings.mdx@@ -110,8 +110,23 @@ from browser_use.browser.context import BrowserContextConfigconfig = BrowserContextConfig(cookies_file="path/to/cookies.json",wait_for_network_idle_page_load_time=3.0,- browser_window_size={'width': 1280, 'height': 1100}+ browser_window_size={'width': 1280, 'height': 1100},+ locale='en-US',+ user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36',+ highlight_elements=True,+ viewport_expansion=500,+ allowed_domains=['google.com', 'wikipedia.org'],)++browser = Browser()+context = BrowserContext(browser=browser, config=config)+++async def run_search():+ agent = Agent(+ browser_context=context,+ task='Your task',+ llm=llm)```## Configuration Options@@ -132,6 +147,22 @@ config = BrowserContextConfig(- **browser_window_size** (default: `{'width': 1280, 'height': 1100}`)Browser window dimensions. The default size is optimized for general use cases and interaction with common UI elements like cookie banners.+- **locale** (default: `None`)+ Specify user locale, for example en-GB, de-DE, etc. Locale will affect navigator.language value, Accept-Language request header value as well as number and date formatting rules. If not provided, defaults to the system default locale.++- **highlight_elements** (default: `True`)+ Highlight interactive elements on the screen with colorfull bounding boxes.++- **viewport_expansion** (default: `500`)+ Viewport expansion in pixels. With this you can controll how much of the page is included in the context of the LLM. If set to -1, all elements from the entire page will be included (this leads to high token usage). If set to 0, only the elements which are visible in the viewport will be included.+ Default is 500 pixels, that means that we inlcude a little bit more than the visible viewport inside the context.++### Restrict URLs++- **allowed_domains** (default: `None`)+ List of allowed domains that the agent can access. If None, all domains are allowed.+ Example: ['google.com', 'wikipedia.org'] - Here the agent will only be able to access google and wikipedia.+### Debug and Recording- **save_recording_path** (default: `None`)