File tree 4 files changed +41
-0
lines changed
4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ workspace = { members = [" Experiments/SeleniumMeme" ] }
1
2
# ──────▄▀▀▄────────────────▄▀▀▄────
2
3
# ─────▐▒▒▒▒▌──────────────▌▒▒▒▒▌───
3
4
# ─────▌▒▒▒▒▐─────────────▐▒▒▒▒▒▐───
Original file line number Diff line number Diff line change
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"
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments