Crates.io | lw-webdriver |
lib.rs | lw-webdriver |
version | 0.4.1 |
source | src |
created_at | 2020-01-19 11:32:58.372088 |
updated_at | 2020-02-05 17:42:14.249115 |
description | A lightweight webdriver client. |
homepage | |
repository | https://github.com/Mubelotix/webdriver |
max_upload_size | |
id | 200073 |
size | 17,209,626 |
This crate allows you to control a web browser (Firefox or chrome) easily. It does not use selenium, which is much more lightweight. It only uses geckodriver or chromedriver (you have to download the one you want to use depending on your browser and place it in your program's directory). This crate can launch the driver and kill his process after, but if one is already running, it will be used. A lot of improvements can be done. Feel free to contribute.
use lw_webdriver::{session::Session, enums::{Browser, Selector}};
use std::{thread, time::Duration};
// start session
let mut session = Session::new(Browser::Firefox, false).unwrap();
// load a website
session.tabs[0].navigate("https://mubelotix.dev/").unwrap();
// click a link
let mut element = session.tabs[0].find(Selector::XPath, "//a[@href='https://www.kerbalspaceprogram.com/']").unwrap().unwrap();
element.click().unwrap();
Run tests one by one:
cargo test -- --test-threads=1
License: MIT