Thirtyfour is a full-featured Selenium library for Rust, inspired by the Python Selenium library.
It supports the W3C WebDriver spec. Tested with Chrome and Firefox although any W3C-compatible WebDriver should work.
Both synchronous and async / await APIs are provided (see examples below).
Features
- Async / await support
- Synchronous support
- Create new browser session via Selenium Standalone or Grid
- Automatically close browser session on drop
- All W3C WebDriver and WebElement methods supported
- Find elements (via all common selectors)
- Send keys to elements, including key-combinations
- Execute Javascript
- Action Chains
- Cookies
- Switch to frame/window/element/alert
- Alert support
- Capture / Save screenshot of browser or individual element
Why 'thirtyfour' ?
It is named after the atomic number for the Selenium chemical element (Se).
Examples
The following examples assume you have a selenium server running at localhost:4444.
You can set this up using docker, as follows:
docker run --rm -d --network host --name selenium-server -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-zinc
Alternatively you can download selenium from the web (https://selenium.dev/downloads) and run it manually:
java -jar selenium-server-standalone-3.141.59.jar
Async example:
use WebDriverResult;
use ;
use tokio;
async
Sync example:
use WebDriverResult;
use ;
LICENSE
This work is dual-licensed under MIT or Apache 2.0. You can choose either license if you use this work.
SPDX-License-Identifier: MIT OR Apache-2.0