Skip to content

Commit 721cb70

Browse files
committed
feat: add small Selenium project
1 parent 69d5f7c commit 721cb70

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
workspace = { members = ["Experiments/SeleniumMeme"] }
12
#──────▄▀▀▄────────────────▄▀▀▄────
23
#─────▐▒▒▒▒▌──────────────▌▒▒▒▒▌───
34
#─────▌▒▒▒▒▐─────────────▐▒▒▒▒▒▐───

Experiments/SeleniumMeme/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "SeleniumMeme"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
thirtyfour = "0.32.0"
10+
tokio = "1.37.0"
9.93 MB
Binary file not shown.

Experiments/SeleniumMeme/src/main.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std::error::Error;
2+
use std::ops::Add;
3+
use std::time::{Duration, SystemTime};
4+
5+
use thirtyfour::prelude::*;
6+
7+
/// This is quick bullshit code and it doesn't work well. Might improve later
8+
#[tokio::main]
9+
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
10+
let caps = DesiredCapabilities::firefox();
11+
let driver = WebDriver::new("http://localhost:4444", caps).await?;
12+
// Navigate to https://wikipedia.org.
13+
driver.goto("https://cpstest.org/2-seconds.php").await?;
14+
15+
let end = SystemTime::now().add(Duration::from_secs(2));
16+
let click_area = driver.find(By::Id("clickarea")).await?;
17+
18+
// Spam click for 2 seconds.
19+
// Because it waits for it to fully finish it is very slow. Maybe if we just spawn a shit ton of threads we can make it go super speed.
20+
while SystemTime::now() < end {
21+
println!("a");
22+
click_area.click().await?;
23+
println!("b");
24+
}
25+
26+
// Always explicitly close the browser.'
27+
driver.quit().await?;
28+
29+
Ok(())
30+
}

0 commit comments

Comments
 (0)