Browser Launcher
A powerful, cross-platform Rust library for launching browsers (Chrome, Edge, Safari, Firefox, etc.) with extensive configuration options. Supports multiple browsers on Windows, macOS, and Linux.
Features
- ๐ Cross-platform support: Windows, macOS, and Linux
- ๐ Multiple browsers: Chrome, Chromium, Edge, Brave, Opera, Vivaldi, etc.
- โ๏ธ Comprehensive options: Headless, security, networking, and more
- ๐งช Well-tested: Unit tests and integration tests included
- ๐ฆ Easy to use: Simple API with extensive CLI support
- ๐ง Extensible: Modular design for easy customization
Installation
As a Library
Add this to your Cargo.toml:
[]
= "1.0.0"
As a CLI Tool
Quick Start
Library Usage
use ;
CLI Usage
Launch Chrome with default settings:
Launch Edge in headless mode:
Launch with custom window size and security disabled:
API Reference
Browser Types
The library supports multiple browsers:
BrowserType::Chrome- Google ChromeBrowserType::ChromeCanary- Google Chrome CanaryBrowserType::Chromium- ChromiumBrowserType::Edge- Microsoft EdgeBrowserType::Brave- Brave BrowserBrowserType::Opera- OperaBrowserType::Vivaldi- VivaldiBrowserType::Custom(path)- Custom browser executable
Options
The Options struct provides extensive configuration:
use ;
let options = Options ;
Browser Detection
The library automatically detects installed browsers:
use ;
let finder = default;
let browsers = finder.find_all;
for browser in browsers
CLI Options
The CLI tool supports all major browser launch options:
Browser Selection
--browser <BROWSER>: Browser type (chrome, chromium, edge, brave, opera, vivaldi)
Launch Modes
--headless: Run in headless mode--incognito: Run in incognito/private mode
Window & Display
--window-size <WIDTHxHEIGHT>: Set window size (e.g., 1920x1080)
Security & Sandbox
--no-sandbox: Disable sandbox (use with caution)--disable-web-security: Disable web security features--ignore-ssl-errors: Ignore SSL certificate errors--allow-insecure-content: Allow running insecure content
Content Control
--disable-extensions: Disable browser extensions--disable-plugins: Disable plugins--disable-images: Disable image loading--disable-javascript: Disable JavaScript execution
Network & Proxy
--proxy-server <URL>: Set proxy server--host-resolver-rules <RULES>: Set host resolver rules
Advanced
--user-agent <STRING>: Set custom user agent--user-data-dir <PATH>: Set user data directory--port <PORT>: Set remote debugging port--starting-url <URL>: Set initial URL to load
Additional Arguments
--browser-flags <FLAGS>: Additional browser flags (comma-separated)--additional-args <ARGS>: Additional arguments (comma-separated)
Examples
Headless Screenshots
use ;
let options = Options ;
let mut launcher = new;
launcher.launch?;
Web Scraping Setup
use ;
let options = Options ;
let mut launcher = new;
launcher.launch?;
Development with Extensions Disabled
Testing with Security Disabled
Platform Support
Windows
- Supports all Chromium-based browsers
- Registry-based and path-based detection
- Compatible with Windows 10 and later
macOS
- Full support for Chrome, Edge, Brave, etc.
- Uses LaunchServices for browser detection
- Compatible with macOS 10.15 and later
Linux
- Supports system-wide and user installations
- Desktop file parsing for browser detection
- Compatible with major Linux distributions
Environment Variables
CHROME_PATH: Specify custom Chrome executable pathBROWSER_PATH: Specify custom browser executable path (preferred)LIGHTHOUSE_CHROMIUM_PATH: Legacy Chromium path (deprecated)HEADLESS: Set to any value to enable headless mode
Testing
Run the test suite:
Run integration tests:
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and add tests
- Run the test suite:
cargo test - Commit your changes:
git commit -am 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
Development
Building
Running CLI
Code Structure
src/
โโโ browser.rs # Browser detection and types
โโโ browser_launcher.rs # Main launcher implementation
โโโ cli.rs # CLI interface
โโโ flags.rs # Default Chrome flags
โโโ lib.rs # Library exports and tests
โโโ utils.rs # Utility functions
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Credits
Inspired by the chrome-launcher TypeScript library.