diff --git a/crates/g3-computer-control/src/webdriver/chrome.rs b/crates/g3-computer-control/src/webdriver/chrome.rs index d96fd6a..e2a3f00 100644 --- a/crates/g3-computer-control/src/webdriver/chrome.rs +++ b/crates/g3-computer-control/src/webdriver/chrome.rs @@ -185,6 +185,10 @@ impl ChromeDriver { Value::String("--lang=en-US,en".to_string()), // Stealth: Disable extensions to avoid detection Value::String("--disable-extensions".to_string()), + // Prevent first-run UI and default browser check popups + Value::String("--no-first-run".to_string()), + Value::String("--no-default-browser-check".to_string()), + Value::String("--disable-popup-blocking".to_string()), ]), ); diff --git a/crates/g3-core/src/tools/webdriver.rs b/crates/g3-core/src/tools/webdriver.rs index aab3b38..748b834 100644 --- a/crates/g3-core/src/tools/webdriver.rs +++ b/crates/g3-core/src/tools/webdriver.rs @@ -43,6 +43,34 @@ fn detect_chrome_for_testing() -> Option { None } +/// Auto-detect ChromeDriver for Testing binary at ~/.chrome-for-testing/. +/// +/// When no `chromedriver_binary` is configured, this checks for a Chrome for +/// Testing chromedriver installation which is version-locked to the matching +/// Chrome for Testing browser, avoiding version mismatch errors. +fn detect_chromedriver_for_testing() -> Option { + let home_str = std::env::var("HOME").ok()?; + let home = std::path::PathBuf::from(home_str); + let cft_dir = home.join(".chrome-for-testing"); + + // Check platform-specific directories + let candidates = [ + cft_dir.join("chromedriver-mac-arm64/chromedriver"), + cft_dir.join("chromedriver-mac-x64/chromedriver"), + // Linux paths + cft_dir.join("chromedriver-linux64/chromedriver"), + ]; + + for candidate in &candidates { + if candidate.exists() { + debug!("Auto-detected ChromeDriver for Testing: {}", candidate.display()); + return Some(candidate.to_string_lossy().into_owned()); + } + } + + None +} + // ───────────────────────────────────────────────────────────────────────────── // Port checking helpers // ───────────────────────────────────────────────────────────────────────────── @@ -170,8 +198,12 @@ async fn start_safari_driver(ctx: &ToolContext<'_, W>) -> Result(ctx: &ToolContext<'_, W>) -> Result { let port = ctx.config.webdriver.chrome_port; - // Resolve Chrome binary: use configured path, or auto-detect Chrome for Testing - let chrome_binary = ctx.config.webdriver.chrome_binary.clone() + // Resolve Chrome binary: use configured path (with tilde expansion), or auto-detect Chrome for Testing + let chrome_binary = ctx.config.webdriver.chrome_binary.as_deref() + .map(|p| { + let expanded = shellexpand::tilde(p); + expanded.into_owned() + }) .or_else(|| detect_chrome_for_testing()); let chrome_binary_ref = chrome_binary.as_deref(); @@ -201,11 +233,14 @@ async fn start_chrome_driver(ctx: &ToolContext<'_, W>) -> Result