Auto-download chrome-headless-shell when system Chrome unavailable#44
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds automatic downloading and setup of
chrome-headless-shellwhen 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
Auto-download chrome-headless-shell: When
_get_chrome_version()fails to detect system Chrome, the setup process now automatically downloadschrome-headless-shellfrom Google's Chrome for Testing infrastructure and caches it locally.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.New function
_download_chrome_headless_shell(): Downloads and cacheschrome-headless-shellbinaries, supporting both explicit version specification viaSHELLNIUM_CHROME_VERSIONand automatic detection of the latest stable version. SetsSHELLNIUM_CHROME_BINenvironment variable for use by WebDriver.Enhanced
_download_chromedriver(): Now accepts an optional version parameter instead of always detecting from system Chrome, allowing it to match downloadedchrome-headless-shellversions.Updated
setup_chromedriver(): Implements fallback logic—if system Chrome is unavailable, auto-downloadschrome-headless-shelland forces headless mode.Binary path support in
new_session(): WhenSHELLNIUM_CHROME_BINis set, includes thebinaryfield in ChromeOptions to point WebDriver to the downloaded binary.Refactored version extraction: Replaces
_get_chrome_major_version()calls with inlinecutoperations 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 downloadSHELLNIUM_HEADLESS: Automatically set totruewhen using downloaded chrome-headless-shellChecklist
bashandzshechostatements)https://claude.ai/code/session_01BhDVezMMyVXL3nEtijSp3v