# chrome-for-testing-manager
Programmatic management of **chrome-for-testing** installations.
- Automatically resolves the configured Chrome for Testing version.
- Automatically downloads chrome-for-testing `chrome` and `chromedriver` binaries into a local cache directory.
- Possibility to spawn the chromedriver process using a random port.
- Optional line-based listener for chromedriver stdout/stderr during a run.
- Built-int session management.
Frees you from the need to
- manually download a chromedriver package matching your locally installed chrome,
- starting and stopping it manually,
- hardcoding the chosen chromedriver port into your tests and
- doing this all-over when trying to test with a new version of chrome.
## Installation
```toml
[dependencies]
chrome-for-testing-manager = "0.9"
rootcause = "0.12"
thirtyfour = "0.36"
# Additional dependencies for the example below.
assertr = "0.5"
tokio = { version = "1", features = ["full"] }
```
## Example
```rust
use assertr::prelude::*;
use chrome_for_testing_manager::{Chromedriver, ChromedriverRunConfig};
use rootcause::Report;
use std::time::Duration;
use thirtyfour::prelude::*;
// This library requires being used in a multithreaded runtime.
// If you want to run a test, use: `#[tokio::test(flavor = "multi_thread")]`.
#[tokio::main]
async fn main() -> Result<(), Report> {
Chromedriver::run(ChromedriverRunConfig::default())
.await?
.with_session(async |session| {
session.goto("https://wikipedia.org").await?;
let search_form = session.find(By::Id("search-form")).await?;
let search_input = search_form.find(By::Id("searchInput")).await?;
search_input.send_keys("selenium").await?;
let submit_btn = search_form.find(By::Css("button[type='submit']")).await?;
submit_btn.click().await?;
// Look for header to implicitly wait for the page to load.
let _heading = session
.query(By::Id("firstHeading"))
.wait(Duration::from_secs(2), Duration::from_millis(100))
.exists()
.await?;
assert_that!(session.title().await?).is_equal_to("Selenium – Wikipedia");
Ok(())
}).await
}
```
## Managed sessions opt-out
The `with_session` function. providing a `thirtyfour` session, called in the example, was only available because
`chrome-for-testing-manager` enables its `thirtyfour` feature by default.
If you just want it's chrome/chromedriver version resolution, download and launch orchestration, declare the dependency
as
```toml
chrome-for-testing-manager = { version = "0.9", default-features = false }
```
instead.
## MSRV
- Starting from version `0.8.0`, the minimum supported rust version is `1.89.0`
- Starting from version `0.7.0`, the minimum supported rust version is `1.85.1`
- Starting from version `0.5.0`, the minimum supported rust version is `1.85.0`
- Starting from version `0.1.0`, the minimum supported rust version is `1.81.0`