Skip to content

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

fix: apply linting and formatting fixes

TC28d90aac5939
diff --git a/browser_use/cli.py b/browser_use/cli.py
index 9697096e1..cdfdc8556 100644
--- a/browser_use/cli.py
+++ b/browser_use/cli.py
@@ -1317,20 +1317,22 @@ async def textual_interface(config: dict[str, Any]):
@click.option('--headless', is_flag=True, help='Run browser in headless mode', default=None)
@click.option('--window-width', type=int, help='Browser window width')
@click.option('--window-height', type=int, help='Browser window height')
[email protected]('--user-data-dir', type=str, help='Path to Chrome user data directory (e.g., ~/Library/Application Support/Google/Chrome)')
+ '--user-data-dir', type=str, help='Path to Chrome user data directory (e.g., ~/Library/Application Support/Google/Chrome)'
+)
@click.option('--profile-directory', type=str, help='Chrome profile directory name (e.g., "Default", "Profile 1")')
@click.option('--cdp-url', type=str, help='Connect to existing Chrome via CDP URL (e.g., http://localhost:9222)')
@click.option('-p', '--prompt', type=str, help='Run a single task without the TUI (headless mode)')
@click.pass_context
def main(ctx: click.Context, debug: bool = False, **kwargs):
"""Browser-Use Interactive TUI or Command Line Executor
-
+
Use --user-data-dir to specify a local Chrome profile directory.
Common Chrome profile locations:
macOS: ~/Library/Application Support/Google/Chrome
Linux: ~/.config/google-chrome
Windows: %LOCALAPPDATA%\\Google\\Chrome\\User Data
-
+
Use --profile-directory to specify which profile within the user data directory.
Examples: "Default", "Profile 1", "Profile 2", etc.
"""
diff --git a/examples/features/chrome_profile_example.py b/examples/features/chrome_profile_example.py
index f7aaca5cc..552cc6efc 100644
--- a/examples/features/chrome_profile_example.py
+++ b/examples/features/chrome_profile_example.py
@@ -5,39 +5,32 @@ This example demonstrates how to use existing Chrome profiles with saved logins
"""
import asyncio
+
from browser_use import Agent
-from browser_use.browser import BrowserSession, BrowserConfig
+from browser_use.browser import BrowserSession
async def main():
- # Example 1: Use a specific Chrome profile with saved logins
- browser_session = BrowserSession(
- user_data_dir="~/Library/Application Support/Google/Chrome",
- profile_directory="Profile 1" # Use "Default" for the default profile
- )
-
- agent = Agent(
- task="Check my Gmail inbox",
- browser_session=browser_session
- )
-
- await agent.run()
-
- # Example 2: Connect to an existing Chrome instance via CDP
- # First, start Chrome with:
- # /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
-
- browser_session_cdp = BrowserSession(
- cdp_url="http://localhost:9222"
- )
-
- agent_cdp = Agent(
- task="Navigate to GitHub and show my profile",
- browser_session=browser_session_cdp
- )
-
- await agent_cdp.run()
-
-
-if __name__ == "__main__":
- asyncio.run(main())
\ No newline at end of file
+ # Example 1: Use a specific Chrome profile with saved logins
+ browser_session = BrowserSession(
+ user_data_dir='~/Library/Application Support/Google/Chrome',
+ profile_directory='Profile 1', # Use "Default" for the default profile
+ )
+
+ agent = Agent(task='Check my Gmail inbox', browser_session=browser_session)
+
+ await agent.run()
+
+ # Example 2: Connect to an existing Chrome instance via CDP
+ # First, start Chrome with:
+ # /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
+
+ browser_session_cdp = BrowserSession(cdp_url='http://localhost:9222')
+
+ agent_cdp = Agent(task='Navigate to GitHub and show my profile', browser_session=browser_session_cdp)
+
+ await agent_cdp.run()
+
+
+if __name__ == '__main__':
+ asyncio.run(main())