#chrome #chromedriver #thirtyfour #install

chrome-for-testing-manager

Programmatic management of chrome-for-testing installations

3 releases (breaking)

new 0.4.0 Feb 16, 2025
0.3.0 Feb 14, 2025
0.2.0 Feb 14, 2025
0.1.0 Jan 17, 2025

#702 in Web programming

Download history 93/week @ 2025-01-13 20/week @ 2025-01-20 3/week @ 2025-01-27 17/week @ 2025-02-03 279/week @ 2025-02-10

335 downloads per month
Used in leptos-keycloak-auth

MIT/Apache

34KB
719 lines

chrome-for-testing-manager

Programmatic management of chrome-for-testing installations.

  • Automatically resolves the requested version. Chromedriver::run_latest_stable is a shortcut for Chromedriver::run(VersionRequest::LatestIn(Channel::Stable), PortRequest::Any).
  • Automatically downloads chrome-for-testing chrome and chromedriver binaries into a local cache directory.
  • Possibility to spawn the chromedriver process using a random port.
  • Built-int session management.

Frees you from the need to

  • manually download a chromedriver package matching your locally installed chrome,
  • starting 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

[dependencies]
thirtyfour = "0.35"
chrome-for-testing-manager = { version = "0.4", features = ["thirtyfour"] }

# Additional dependencies for the example below.
assertr = "0.1"
anyhow = "1"
tokio = { version = "1", features = ["full"] }

Example

use assertr::prelude::*;
use chrome_for_testing_manager::prelude::*;
use thirtyfour::prelude::*;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let mut chromedriver = Chromedriver::run_latest_stable().await?;
    let (handle, session) = chromedriver.new_session().await?;

    // Navigate to https://wikipedia.org.
    session.goto("https://wikipedia.org").await?;
    let elem_form = session.find(By::Id("search-form")).await?;

    // Find element from element.
    let elem_text = elem_form.find(By::Id("searchInput")).await?;

    // Type in the search terms.
    elem_text.send_keys("selenium").await?;

    // Click the search button.
    let elem_button = elem_form.find(By::Css("button[type='submit']")).await?;
    elem_button.click().await?;

    // Look for header to implicitly wait for the page to load.
    session.find(By::ClassName("firstHeading")).await?;
    assert_that(session.title().await?).is_equal_to("Selenium - Wikipedia");

    // Always explicitly close the session/browser.
    chromedriver.quit(handle).await?;

    Ok(())
}

Dependencies

~11–24MB
~339K SLoC