#selenium #browser #testing #automation

selenium-rs

selenium-rs is a client for the selenium webdriver spec (https://www.w3.org/TR/webdriver1/). It is aimed to simplify behavior driven testing in rust, and for automating browser interaction.

3 releases

Uses old Rust 2015

0.1.2 Feb 13, 2020
0.1.1 Sep 12, 2018
0.1.0 Sep 12, 2018

#685 in Hardware support

Download history 31/week @ 2024-06-17 14/week @ 2024-06-24 9/week @ 2024-07-01 10/week @ 2024-07-08 37/week @ 2024-07-15 18/week @ 2024-07-22 7/week @ 2024-07-29 14/week @ 2024-08-05 10/week @ 2024-08-12 13/week @ 2024-08-19 21/week @ 2024-08-26 15/week @ 2024-09-02 34/week @ 2024-09-09 21/week @ 2024-09-16 35/week @ 2024-09-23 59/week @ 2024-09-30

151 downloads per month

MIT license

24KB
438 lines

Selenium-rs

GitHub issues

About

Selenium-rs is a simple client for the selenium webdriver. Its built to work with the webdriver protocol (spec found here). It currently supports the chrome Driver, and Gecko (firefox) support is on the way.

Installation

[dependencies]
selenium-rs = "0.1.0"

Note that selenium-rs also requires a running instance of the selenium webdriver, which can be found here. Simply download the jar and run it to instantiate the selenium webdriver server.

Documentation: docs.rs

Sample Usage

Example - Navigating to a web page

use selenium_rs::webdriver::{Browser,WebDriver};

let mut driver= WebDriver::new(Browser::Chrome);
driver.start_session();

driver.navigate("https://www.rust-lang.org"); 
assert_eq!(driver.get_current_url().unwrap(), String::from("https://www.rust-lang.org/"));
use selenium_rs::webdriver::{Browser, WebDriver, Selector};
let mut driver = WebDriver::new(Browser::Chrome);

driver.start_session();
driver.navigate("http://google.com");
let search_bar = driver.find_element(Selector::CSS, "input[maxlength=\"2048\"]").unwrap();

search_bar.type_text("selenium-rs github");
let search_button = driver.find_element(Selector::CSS, "input[name=\"btnK\"]").unwrap();
search_button.click();
search_button.click();

Example - Inspecting attributes of an element

use selenium_rs::webdriver::{Selector, Browser, WebDriver};
use selenium_rs::element::Element;

let mut driver = WebDriver::new(Browser::Chrome);
driver.start_session();
driver.navigate("http://www.google.com");
let search_form =  driver.find_element(Selector::CSS, "#searchform").unwrap();
assert!(search_form.get_css_value("min-width").unwrap() == "980px");

Current Status

Currently, the project supports many of the more important functionalities provided by the webdriver spec. However, it is still a fair bit away from complete. Support will get periodically added as I find the time to finish implementing everything described in the webdriver spec. In-progress features will be tracked here.

Note: Currently only tested with Selenium 3.14

Contribution

Pull requests are always welcome! Please see the issue tracker for currently in-progress features, improvements, and bugfixes.

Licence

This is provided under the MIT license.

Dependencies

~20MB
~417K SLoC