Deploy OpenBrowser with saved authentication using browser profiles.
1. Test Locally with Existing Chrome Profile
Use your existing Chrome profile with saved logins:
from openbrowser import Agent, Browser, ChatGoogle
browser = Browser(
executable_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
user_data_dir='~/Library/Application Support/Google/Chrome',
profile_directory='Default',
)
agent = Agent(task="your task", browser=browser, llm=ChatGoogle())
await agent.run()
Close Chrome completely before running to avoid conflicts.
Chrome Profile Paths by OS
| OS | User Data Dir |
|---|
| macOS | ~/Library/Application Support/Google/Chrome |
| Windows | %LOCALAPPDATA%\Google\Chrome\User Data |
| Linux | ~/.config/google-chrome |
2. Use Persistent Browser Session
For production, use a dedicated user data directory:
from openbrowser import Agent, Browser, ChatGoogle
import tempfile
# Create persistent browser with custom user data
browser = Browser(
user_data_dir='./browser_data', # Persists between runs
headless=False, # Set True for production
)
agent = Agent(
task="Login to example.com and check notifications",
browser=browser,
llm=ChatGoogle()
)
await agent.run()
3. Remote Browser via CDP
Connect to a remote browser using Chrome DevTools Protocol:
from openbrowser import Agent, Browser, ChatGoogle
# Connect to existing Chrome instance
# Start Chrome with: chrome --remote-debugging-port=9222
browser = Browser(cdp_url="http://localhost:9222")
agent = Agent(
task="your task",
browser=browser,
llm=ChatGoogle()
)
await agent.run()
Best Practices
- Use environment variables for API keys
- Run headless in production (
headless=True)
- Set allowed_domains to restrict navigation
- Use proxy for rate limiting and geo-targeting
- Monitor with telemetry for debugging
from openbrowser import Agent, Browser, ChatGoogle
browser = Browser(
headless=True,
allowed_domains=['*.example.com'],
proxy={'server': 'http://proxy:8080'},
)
agent = Agent(
task="Production task",
browser=browser,
llm=ChatGoogle(),
)