mirror of
https://github.com/browser-use/browser-use
synced 2026-05-06 17:52:15 +02:00
Merge branch 'main' into test-screenshot
This commit is contained in:
40
AGENTS.MD
40
AGENTS.MD
@@ -50,8 +50,7 @@ source .venv/bin/activate
|
||||
```
|
||||
```bash install browser-use & chromium
|
||||
uv pip install browser-use
|
||||
uvx playwright install chromium --with-deps
|
||||
# Note: this does NOT install playwright, only chromium
|
||||
browser-use install
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="pip">
|
||||
@@ -63,12 +62,40 @@ source .venv/bin/activate
|
||||
```
|
||||
```bash install browser-use & chromium
|
||||
pip install browser-use
|
||||
pip install playwright && playwright install chromium --with-deps
|
||||
browser-use install
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Info>On Windows, use `.venv\Scripts\activate` to activate the environment.</Info>
|
||||
<Tabs>
|
||||
<Tab title="Mac/Linux">
|
||||
```bash activate environment theme={null}
|
||||
source .venv/bin/activate
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Windows">
|
||||
```bash activate environment theme={null}
|
||||
.venv\Scripts\activate
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Tabs>
|
||||
<Tab title="uv">
|
||||
```bash install browser-use & chromium theme={null}
|
||||
uv pip install browser-use
|
||||
browser-use install
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="pip">
|
||||
```bash install browser-use & chromium theme={null}
|
||||
pip install browser-use
|
||||
browser-use install
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## 2. Choose your favorite LLM
|
||||
Create a `.env` file and add your API key.
|
||||
@@ -196,8 +223,7 @@ source .venv/bin/activate
|
||||
```
|
||||
```bash install browser-use & chromium
|
||||
uv pip install browser-use
|
||||
uvx playwright install chromium --with-deps
|
||||
# Note: this does NOT install playwright, only chromium
|
||||
browser-use install
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="pip">
|
||||
@@ -209,7 +235,7 @@ source .venv/bin/activate
|
||||
```
|
||||
```bash install browser-use & chromium
|
||||
pip install browser-use
|
||||
pip install playwright && playwright install chromium --with-deps
|
||||
browser-use install
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
@@ -63,9 +63,9 @@ uv sync
|
||||
BROWSER_USE_API_KEY=your-key
|
||||
```
|
||||
|
||||
**4. Download chromium using playwright's shortcut:**
|
||||
**4. Install Chromium browser:**
|
||||
```bash
|
||||
uvx playwright install chromium --with-deps --no-shell
|
||||
browser-use install
|
||||
```
|
||||
|
||||
**5. Run your first agent:**
|
||||
|
||||
@@ -314,14 +314,16 @@ class LocalBrowserWatchdog(BaseWatchdog):
|
||||
|
||||
async def _install_browser_with_playwright(self) -> str:
|
||||
"""Get browser executable path from playwright in a subprocess to avoid thread issues."""
|
||||
import platform
|
||||
|
||||
# Build command - only use --with-deps on Linux (it fails on Windows/macOS)
|
||||
cmd = ['uvx', 'playwright', 'install', 'chrome']
|
||||
if platform.system() == 'Linux':
|
||||
cmd.append('--with-deps')
|
||||
|
||||
# Run in subprocess with timeout
|
||||
process = await asyncio.create_subprocess_exec(
|
||||
'uvx',
|
||||
'playwright',
|
||||
'install',
|
||||
'chrome',
|
||||
'--with-deps',
|
||||
*cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
@@ -333,7 +335,7 @@ class LocalBrowserWatchdog(BaseWatchdog):
|
||||
if browser_path:
|
||||
return browser_path
|
||||
self.logger.error(f'[LocalBrowserWatchdog] ❌ Playwright local browser installation error: \n{stdout}\n{stderr}')
|
||||
raise RuntimeError('No local browser path found after: uvx playwright install chrome --with-deps')
|
||||
raise RuntimeError('No local browser path found after: uvx playwright install chrome')
|
||||
except TimeoutError:
|
||||
# Kill the subprocess if it times out
|
||||
process.kill()
|
||||
|
||||
@@ -11,6 +11,30 @@ if '--mcp' in sys.argv:
|
||||
os.environ['BROWSER_USE_SETUP_LOGGING'] = 'false'
|
||||
logging.disable(logging.CRITICAL)
|
||||
|
||||
# Special case: install command doesn't need CLI dependencies
|
||||
if len(sys.argv) > 1 and sys.argv[1] == 'install':
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
print('📦 Installing Chromium browser + system dependencies...')
|
||||
print('⏳ This may take a few minutes...\n')
|
||||
|
||||
# Build command - only use --with-deps on Linux (it fails on Windows/macOS)
|
||||
cmd = ['uvx', 'playwright', 'install', 'chromium']
|
||||
if platform.system() == 'Linux':
|
||||
cmd.append('--with-deps')
|
||||
cmd.append('--no-shell')
|
||||
|
||||
result = subprocess.run(cmd)
|
||||
|
||||
if result.returncode == 0:
|
||||
print('\n✅ Installation complete!')
|
||||
print('🚀 Ready to use! Run: uvx browser-use')
|
||||
else:
|
||||
print('\n❌ Installation failed')
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
@@ -2004,5 +2028,30 @@ def auth():
|
||||
asyncio.run(run_auth_command())
|
||||
|
||||
|
||||
@main.command()
|
||||
def install():
|
||||
"""Install Chromium browser with system dependencies"""
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
print('📦 Installing Chromium browser + system dependencies...')
|
||||
print('⏳ This may take a few minutes...\n')
|
||||
|
||||
# Build command - only use --with-deps on Linux (it fails on Windows/macOS)
|
||||
cmd = ['uvx', 'playwright', 'install', 'chromium']
|
||||
if platform.system() == 'Linux':
|
||||
cmd.append('--with-deps')
|
||||
cmd.append('--no-shell')
|
||||
|
||||
result = subprocess.run(cmd)
|
||||
|
||||
if result.returncode == 0:
|
||||
print('\n✅ Installation complete!')
|
||||
print('🚀 Ready to use! Run: uvx browser-use')
|
||||
else:
|
||||
print('\n❌ Installation failed')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -38,7 +38,7 @@ source .venv/bin/activate
|
||||
uv pip install -e .
|
||||
|
||||
# 4. Install browser runtime once
|
||||
playwright install chromium --with-deps --no-shell
|
||||
browser-use install
|
||||
```
|
||||
|
||||
### 1) Claude Code
|
||||
|
||||
@@ -22,8 +22,7 @@ source .venv/bin/activate
|
||||
```
|
||||
```bash install browser-use & chromium
|
||||
uv pip install browser-use
|
||||
uvx playwright install chromium --with-deps
|
||||
# Note: this does NOT install playwright, only chromium
|
||||
browser-use install
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="pip">
|
||||
@@ -35,7 +34,7 @@ source .venv/bin/activate
|
||||
```
|
||||
```bash install browser-use & chromium
|
||||
pip install browser-use
|
||||
pip install playwright && playwright install chromium --with-deps
|
||||
browser-use install
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
@@ -20,7 +20,7 @@ from browser_use import Agent, ChatBrowserUse
|
||||
|
||||
async def main():
|
||||
llm = ChatBrowserUse()
|
||||
task = "We are testing the send_keys function. Go to https://inputtypes.com/ and focus the input box and type 'hello world'. DO NOT use the input_text action. Only use the send_keys action. Mark the task as done right after using the send_keys action."
|
||||
task = "Search Google for 'what is browser automation' and tell me the top 3 results"
|
||||
agent = Agent(task=task, llm=llm)
|
||||
await agent.run()
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name = "browser-use"
|
||||
description = "Make websites accessible for AI agents"
|
||||
authors = [{ name = "Gregor Zunic" }]
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11,<4.0"
|
||||
classifiers = [
|
||||
|
||||
Reference in New Issue
Block a user