#web-driver #selenium #automated-testing #automation #chromedriver #geckodriver

thirtyfour

Thirtyfour is a Selenium / WebDriver library for Rust, for automated website UI testing. Tested on Chrome and Firefox, but any webdriver-capable browser should work

99 releases

0.35.0 Nov 25, 2024
0.33.1 Aug 29, 2024
0.33.0 Jul 21, 2024
0.32.0-rc.10 Feb 19, 2024
0.1.0 Nov 30, 2019

#14 in HTTP client

Download history 4781/week @ 2024-08-21 5838/week @ 2024-08-28 4650/week @ 2024-09-04 4295/week @ 2024-09-11 3520/week @ 2024-09-18 4139/week @ 2024-09-25 4590/week @ 2024-10-02 3316/week @ 2024-10-09 5182/week @ 2024-10-16 5010/week @ 2024-10-23 4047/week @ 2024-10-30 4220/week @ 2024-11-06 3934/week @ 2024-11-13 5719/week @ 2024-11-20 5197/week @ 2024-11-27 4705/week @ 2024-12-04

20,145 downloads per month
Used in 27 crates (22 directly)

MIT/Apache

420KB
6.5K SLoC

Crates.io docs.rs Build Status code coverage

thirtyfour

Thirtyfour is a Selenium / WebDriver library for Rust, for automated website UI testing.

Features

  • All W3C WebDriver and WebElement methods supported
  • Create new browser session directly via WebDriver (e.g. chromedriver)
  • Create new browser session via Selenium Standalone or Grid
  • Find elements (via all common selectors e.g. Id, Class, CSS, Tag, XPath)
  • Send keys to elements, including key-combinations
  • Execute Javascript
  • Action Chains
  • Get and set cookies
  • Switch to frame/window/element/alert
  • Shadow DOM support
  • Alert support
  • Capture / Save screenshot of browser or individual element as PNG
  • Chrome DevTools Protocol (CDP) support (limited)
  • Advanced query interface including explicit waits and various predicates
  • Component Wrappers (similar to Page Object Model)

Feature Flags

  • rustls-tls: (Default) Use rustls to provide TLS support (via reqwest).
  • native-tls: Use native TLS (via reqwest).
  • component: (Default) Enable the Component derive macro (via thirtyfour_macros).

Examples

The examples assume you have chromedriver running on your system.

You can use Selenium (see instructions below) or you can use chromedriver directly by downloading the chromedriver that matches your Chrome version, from here: https://chromedriver.chromium.org/downloads

Then run it like this:

chromedriver

Example (async):

To run this example:

cargo run --example tokio_async
use thirtyfour::prelude::*;

#[tokio::main]
async fn main() -> WebDriverResult<()> {
     let caps = DesiredCapabilities::chrome();
     let driver = WebDriver::new("http://localhost:9515", caps).await?;

     // Navigate to https://wikipedia.org.
     driver.goto("https://wikipedia.org").await?;
     let elem_form = driver.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.
     driver.find(By::ClassName("firstHeading")).await?;
     assert_eq!(driver.title().await?, "Selenium - Wikipedia");
    
     // Always explicitly close the browser.
     driver.quit().await?;

     Ok(())
}

Minimum Supported Rust Version

The MSRV for thirtyfour is currently latest, and so its guaranteed to run the latest stable release.

LICENSE

This work is dual-licensed under MIT or Apache 2.0. You can choose either license if you use this work.

See the NOTICE file for more details.

SPDX-License-Identifier: MIT OR Apache-2.0

Dependencies

~10–22MB
~308K SLoC