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
fix cloud --help to show custom usage, tighten test assertions
ShawnPanac26f228e5afc
diff --git a/browser_use/skill_cli/main.py b/browser_use/skill_cli/main.pyindex 8698eb6d2..c61f090bd 100755--- a/browser_use/skill_cli/main.py+++ b/browser_use/skill_cli/main.py@@ -132,6 +132,16 @@ if '--template' in sys.argv:init_main()sys.exit(0)+# Handle 'cloud --help' / 'cloud -h' early — argparse intercepts --help before+# REMAINDER can capture it, so we route to our custom usage printer directly+if _get_subcommand() == 'cloud' and any(arg in sys.argv for arg in ('--help', '-h')):+ # Only intercept if --help comes after 'cloud', not before it+ cloud_idx = sys.argv.index('cloud')+ if any(arg in sys.argv[cloud_idx + 1:] for arg in ('--help', '-h')):+ from browser_use.skill_cli.commands.cloud import handle_cloud_command++ sys.exit(handle_cloud_command(['--help']))+# =============================================================================# Utility functions (inlined to avoid imports)# =============================================================================diff --git a/tests/ci/test_cli_cloud_connect.py b/tests/ci/test_cli_cloud_connect.pyindex 6db2da79c..4e27b2f69 100644--- a/tests/ci/test_cli_cloud_connect.py+++ b/tests/ci/test_cli_cloud_connect.py@@ -38,11 +38,11 @@ def test_cloud_connect_mutual_exclusivity_profile():def test_cloud_connect_shows_in_usage():"""cloud help should list connect."""- result = run_cli('cloud')+ result = run_cli('cloud', '--help')assert 'connect' in result.stdout.lower()def test_cloud_connect_help_shows_in_epilog():"""Main --help epilog should mention cloud connect."""result = run_cli('--help')- assert 'cloud connect' in result.stdout.lower() or 'cloud' in result.stdout.lower()+ assert 'cloud connect' in result.stdout.lower()diff --git a/tests/ci/test_cli_sessions.py b/tests/ci/test_cli_sessions.pyindex 859660f27..64d46e554 100644--- a/tests/ci/test_cli_sessions.py+++ b/tests/ci/test_cli_sessions.py@@ -4,8 +4,6 @@ Validates argument parsing, socket/PID path generation, session name validation,and path agreement between main.py (stdlib-only) and utils.py."""-import re-import pytestfrom browser_use.skill_cli.main import (@@ -75,16 +73,6 @@ def test_session_name_invalid():validate_session_name(name)-def test_session_name_regex_in_main():- """Verify main.py uses the same regex as utils.validate_session_name."""- pattern = re.compile(r'^[a-zA-Z0-9_-]+$')- assert pattern.match('default')- assert pattern.match('my-session_1')- assert not pattern.match('../evil')- assert not pattern.match('')- assert not pattern.match('a b')--# ---------------------------------------------------------------------------# Path generation# ---------------------------------------------------------------------------@@ -103,7 +91,7 @@ def test_pid_path_includes_session():def test_default_session_paths():sock = _get_socket_path('default')pid = _get_pid_path('default')- assert 'default' in sock or 'tcp://' in sock+ assert 'default.sock' in sock or 'tcp://' in sockassert pid.name == 'default.pid'