Skip to content

Auto-download chrome-headless-shell when system Chrome unavailable#44

Merged
Rasukarusan merged 4 commits into
masterfrom
claude/shellnium-ai-agent-usecases-zx2RY
Mar 28, 2026
Merged

Auto-download chrome-headless-shell when system Chrome unavailable#44
Rasukarusan merged 4 commits into
masterfrom
claude/shellnium-ai-agent-usecases-zx2RY

Conversation

@Rasukarusan

Copy link
Copy Markdown
Owner

What does this PR do?

This PR adds automatic downloading and setup of chrome-headless-shell when no system Chrome installation is detected. It also refactors ChromeDriver setup to accept an explicit Chrome version parameter, enabling better version matching and support for downloaded binaries.

Key Changes

  1. Auto-download chrome-headless-shell: When _get_chrome_version() fails to detect system Chrome, the setup process now automatically downloads chrome-headless-shell from Google's Chrome for Testing infrastructure and caches it locally.

  2. New helper function _get_chrome_for_testing_json(): Extracts common JSON fetching logic for Chrome for Testing API calls, reducing duplication and improving error handling.

  3. New function _download_chrome_headless_shell(): Downloads and caches chrome-headless-shell binaries, supporting both explicit version specification via SHELLNIUM_CHROME_VERSION and automatic detection of the latest stable version. Sets SHELLNIUM_CHROME_BIN environment variable for use by WebDriver.

  4. Enhanced _download_chromedriver(): Now accepts an optional version parameter instead of always detecting from system Chrome, allowing it to match downloaded chrome-headless-shell versions.

  5. Updated setup_chromedriver(): Implements fallback logic—if system Chrome is unavailable, auto-downloads chrome-headless-shell and forces headless mode.

  6. Binary path support in new_session(): When SHELLNIUM_CHROME_BIN is set, includes the binary field in ChromeOptions to point WebDriver to the downloaded binary.

  7. Refactored version extraction: Replaces _get_chrome_major_version() calls with inline cut operations for consistency.

Environment Variables

  • SHELLNIUM_CHROME_BIN: Path to downloaded chrome-headless-shell binary (set automatically)
  • SHELLNIUM_CHROME_VERSION: Optional explicit version for chrome-headless-shell download
  • SHELLNIUM_HEADLESS: Automatically set to true when using downloaded chrome-headless-shell

Checklist

  • Tested with bash and zsh
  • Variables are properly quoted
  • No debug output (e.g., stray echo statements)

https://claude.ai/code/session_01BhDVezMMyVXL3nEtijSp3v

claude and others added 4 commits March 22, 2026 13:07
When no system Chrome/Chromium is installed, shellnium now automatically
downloads Google's chrome-headless-shell (~50MB) and matching ChromeDriver,
making shellnium fully portable — just bash, curl, and jq are needed.

This enables zero-setup browser automation for AI agents and CI/CD
environments where installing Chrome is impractical.

New env vars:
- SHELLNIUM_CHROME_VERSION: pin a specific Chrome version
- SHELLNIUM_CHROME_BIN: set automatically, or override manually

https://claude.ai/code/session_01BhDVezMMyVXL3nEtijSp3v
@Rasukarusan Rasukarusan merged commit e5bd217 into master Mar 28, 2026
2 checks passed
@Rasukarusan Rasukarusan deleted the claude/shellnium-ai-agent-usecases-zx2RY branch March 28, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants