[][src]Crate thirtyfour

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

It supports the full W3C WebDriver spec. Tested with Chrome and Firefox although any W3C-compatible WebDriver should work.

Async only (tokio and async-std runtimes supported via feature flags). For synchronous support, use the thirtyfour_sync crate instead.


  • All W3C WebDriver and WebElement methods supported
  • Async / await support (both tokio and async-std runtimes supported via feature flags)
  • Synchronous support (use the thirtyfour_sync crate)
  • Create new browser session directly via WebDriver (e.g. chromedriver)
  • Create new browser session via Selenium Standalone or Grid
  • Automatically close browser session on drop
  • 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

Feature Flags

Support for tokio and async-std async runtimes, and support for synchronous http, are provided via feature flags.

  • tokio-runtime: (Default) Use the tokio async runtime with the reqwest http client.

  • async-std-runtime: Use the async-std runtime with the surf http client.

    NOTE: You cannot combine async-std-runtime with tokio-runtime.

There are four reqwest-*-tls*-features, which enable the respective features in the reqwest dependency:

  • reqwest-default-tls (enabled by default): Provides TLS support to connect over HTTPS.
  • reqwest-native-tls: Enables TLS functionality provided by native-tls.
  • reqwest-native-tls-vendored: Enables the vendored feature of native-tls.
  • reqwest-rustls-tls: Enables TLS functionality provided by rustls.


The following examples assume you have a selenium server running at localhost:4444, and a demo web app running at http://webappdemo

You can set these up using docker-compose, as follows:

This example is not tested
docker-compose up -d

The included web app demo is purely for demonstration / unit testing purposes and is not required in order to use this library in other projects.

Example (async):

use thirtyfour::prelude::*;
use tokio;

async fn main() -> WebDriverResult<()> {
    let caps = DesiredCapabilities::chrome();
    let driver = WebDriver::new("http://localhost:4444/wd/hub", &caps).await?;

    // Navigate to URL.

    // Navigate to page, by chaining futures together and awaiting the result.

    // Find element.
    let elem_div = driver.find_element(By::Css("div[data-section='section-input']")).await?;

    // Find element from element.
    let elem_text = elem_div.find_element(By::Name("input1")).await?;

    // Type in the search terms.

    // Click the button.
    let elem_button = elem_div.find_element(By::Tag("button")).await?;

    // Get text value of element.
    let elem_result = driver.find_element(By::Id("input-result")).await?;
    assert_eq!(elem_result.text().await?, "selenium");



pub use common::capabilities::chrome::ChromeCapabilities;
pub use common::capabilities::desiredcapabilities::*;
pub use common::capabilities::edge::EdgeCapabilities;
pub use common::capabilities::firefox::FirefoxCapabilities;
pub use common::capabilities::ie::InternetExplorerCapabilities;
pub use common::capabilities::opera::OperaCapabilities;
pub use common::capabilities::safari::SafariCapabilities;
pub use common::command::By;
pub use common::command::ExtensionCommand;
pub use common::command::RequestMethod;
pub use common::cookie::Cookie;
pub use common::keys::Keys;
pub use common::keys::TypingData;
pub use common::scriptargs::ScriptArgs;
pub use common::types::*;



Action chains allow for more complex user interactions with the keyboard and mouse.


Common types used by both async and sync implementations.


Error types.


Async HTTP client traits.


Allow importing the common async structs via use thirtyfour::prelude::*.


Miscellaneous support functions for thirtyfour tests.



Struct for managing alerts.


NOTE: For WebDriver method documentation, see the WebDriverCommands trait.


Struct for switching between frames/windows/alerts.


The WebElement struct encapsulates a single element on a page.



All browser-level W3C WebDriver commands are implemented under this trait.

Type Definitions


The WebDriver struct represents a browser session.