The Browser Use CLI provides direct browser control without writing Python code. Install the package and run commands to navigate, interact, manage cookies, and execute agent tasks.
Installation
Verify the installation:
Commands
Navigation
Navigate to a URL:
browser-use navigate --url "https://example.com"
Go back or forward:
browser-use back
browser-use forward
Refresh the current page:
Interaction
Click an element by selector:
browser-use click --selector "#submit-button"
Type text into an input field:
browser-use type --selector "#search" --text "browser automation"
Scroll the page:
browser-use scroll --direction down --amount 500
Take a screenshot:
browser-use screenshot --output screenshot.png
Cookies
Export cookies to a file:
browser-use cookies export --output cookies.json
Import cookies from a file:
browser-use cookies import --input cookies.json
Clear all cookies:
browser-use cookies clear
Wait
Wait for an element to appear:
browser-use wait --selector "#loading" --state hidden
Wait for a specific duration (in milliseconds):
browser-use wait --timeout 3000
JavaScript
Execute JavaScript in the browser:
browser-use js --code "document.title"
Execute JavaScript from a file:
browser-use js --file script.js
Agent tasks
Run an AI agent to complete a task:
browser-use agent --task "Find the top post on Hacker News"
Specify a model:
browser-use agent --task "Search for flights to Paris" --model gpt-4.1-mini
Use a custom prompt:
browser-use agent --task "Fill out the contact form" --system-prompt "Be concise and efficient"
Cloud sessions
Connect to a Browser Use Cloud session:
browser-use cloud connect --session-id <session-id>
Create a new cloud session:
List active sessions:
Cloud sessions require a BROWSER_USE_API_KEY. Set it in your environment or .env file.
Tunnels
Expose your local browser to the cloud:
Stop an active tunnel:
Check tunnel status:
browser-use tunnel status
Profile management
Create a browser profile:
browser-use profile create --name "work"
List available profiles:
Use a specific profile:
browser-use navigate --url "https://example.com" --profile "work"
Delete a profile:
browser-use profile delete --name "work"
Usage examples
Complete workflow
Navigate, interact, and extract data:
# Start browser and navigate
browser-use navigate --url "https://news.ycombinator.com"
# Click on a link
browser-use click --selector ".titleline a"
# Take a screenshot
browser-use screenshot --output page.png
# Extract page title with JavaScript
browser-use js --code "document.title"
Authentication with cookies
Save and restore login state:
# Navigate and log in manually or with agent
browser-use agent --task "Log in to example.com with username demo"
# Export cookies for later use
browser-use cookies export --output auth-cookies.json
# In a new session, restore cookies
browser-use cookies import --input auth-cookies.json
browser-use navigate --url "https://example.com/dashboard"
Cloud-based automation
Run tasks in the cloud:
# Create a cloud session with a profile
browser-use cloud create --profile "authenticated-user"
# Run an agent task in the cloud
browser-use agent --task "Extract data from dashboard" --cloud
Environment variables
| Variable | Description |
|---|
BROWSER_USE_API_KEY | API key for cloud features |
BROWSER_USE_HEADLESS | Run browser in headless mode (true/false) |
BROWSER_USE_PROFILE | Default profile to use |