Revert to Safari as default WebDriver browser

Chrome headless has too many issues:
- Session creation hangs when Chrome is already running
- Cloudflare and other bot protection blocks headless browsers
- Version mismatch issues between Chrome and ChromeDriver

Safari is more reliable for web automation on macOS.
Chrome headless is still available via --chrome-headless flag.
This commit is contained in:
Dhanji R. Prasanna
2025-12-16 12:36:18 +11:00
parent bbe57b4764
commit faa6512b1f
4 changed files with 10 additions and 10 deletions

View File

@@ -245,7 +245,7 @@ See `config.example.toml` for a complete configuration example.
## WebDriver Browser Automation ## WebDriver Browser Automation
G3 includes WebDriver support for browser automation tasks. Chrome headless is the default (no visible browser window), with Safari available as an alternative. G3 includes WebDriver support for browser automation tasks. Safari is the default, with Chrome headless available as an alternative.
**One-Time Setup** (macOS only): **One-Time Setup** (macOS only):
@@ -266,11 +266,11 @@ safaridriver --enable # Requires password
**Usage**: **Usage**:
```bash ```bash
# Use Chrome in headless mode (default, no visible window, runs in background) # Use Safari (default, opens a visible browser window)
g3 --webdriver g3 --webdriver
# Use Safari (opens a visible browser window) # Use Chrome in headless mode (no visible window, runs in background)
g3 --webdriver --safari g3 --chrome-headless
``` ```
**Chrome Setup Options**: **Chrome Setup Options**:

View File

@@ -106,10 +106,10 @@ max_actions_per_second = 5
enabled = false enabled = false
safari_port = 4444 safari_port = 4444
chrome_port = 9515 chrome_port = 9515
# Browser to use: "safari" or "chrome-headless" (default) # Browser to use: "safari" (default) or "chrome-headless"
# Safari opens a visible browser window # Safari opens a visible browser window
# Chrome headless runs in the background without a visible window # Chrome headless runs in the background without a visible window
browser = "chrome-headless" browser = "safari"
# Optional: Path to Chrome binary (e.g., Chrome for Testing) # Optional: Path to Chrome binary (e.g., Chrome for Testing)
# If not set, ChromeDriver will use the default Chrome installation # If not set, ChromeDriver will use the default Chrome installation
# Use this to avoid version mismatch issues between Chrome and ChromeDriver # Use this to avoid version mismatch issues between Chrome and ChromeDriver

View File

@@ -343,11 +343,11 @@ pub struct Cli {
#[arg(long)] #[arg(long)]
pub webdriver: bool, pub webdriver: bool,
/// Use Chrome in headless mode for WebDriver (this is the default) /// Use Chrome in headless mode for WebDriver (instead of Safari)
#[arg(long)] #[arg(long)]
pub chrome_headless: bool, pub chrome_headless: bool,
/// Use Safari for WebDriver (instead of headless Chrome) /// Use Safari for WebDriver (this is the default)
#[arg(long)] #[arg(long)]
pub safari: bool, pub safari: bool,

View File

@@ -119,9 +119,9 @@ pub struct ComputerControlConfig {
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum WebDriverBrowser { pub enum WebDriverBrowser {
#[default]
Safari, Safari,
#[serde(rename = "chrome-headless")] #[serde(rename = "chrome-headless")]
#[default]
ChromeHeadless, ChromeHeadless,
} }
@@ -157,7 +157,7 @@ impl Default for WebDriverConfig {
safari_port: 4444, safari_port: 4444,
chrome_port: 9515, chrome_port: 9515,
chrome_binary: None, chrome_binary: None,
browser: WebDriverBrowser::ChromeHeadless, browser: WebDriverBrowser::Safari,
} }
} }
} }