Add Chrome for Testing support for reliable WebDriver automation

- Add setup script (scripts/setup-chrome-for-testing.sh) that downloads
  matching Chrome and ChromeDriver versions from Google's CDN
- Add chrome_binary config option to specify custom Chrome binary path
- Update ChromeDriver to support custom binary via with_port_headless_and_binary()
- Update README with Chrome for Testing setup instructions
- Update config.example.toml with chrome_binary documentation

Chrome for Testing is Google's dedicated browser for automated testing
that guarantees version compatibility with ChromeDriver, avoiding the
common 'version mismatch' errors when Chrome auto-updates.
This commit is contained in:
Dhanji R. Prasanna
2025-12-15 17:02:30 +11:00
parent d142cdfffe
commit 81cba42c8d
6 changed files with 165 additions and 3 deletions

View File

@@ -5605,8 +5605,13 @@ impl<W: UiWriter> Agent<W> {
// Wait before each attempt (200ms between retries, total max ~2s)
tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
// Try to connect to ChromeDriver in headless mode
match g3_computer_control::ChromeDriver::with_port_headless(port).await {
// Try to connect to ChromeDriver in headless mode (with optional custom binary)
let driver_result = match &self.config.webdriver.chrome_binary {
Some(binary) => g3_computer_control::ChromeDriver::with_port_headless_and_binary(port, Some(binary)).await,
None => g3_computer_control::ChromeDriver::with_port_headless(port).await,
};
match driver_result {
Ok(driver) => {
let session = std::sync::Arc::new(tokio::sync::Mutex::new(WebDriverSession::Chrome(driver)));
*self.webdriver_session.write().await = Some(session);