summaryrefslogtreecommitdiff
path: root/src/web.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-01-12 17:23:28 -0800
committerFuwn <[email protected]>2024-01-12 17:23:28 -0800
commit83284cd99bc77232e934c0eb505b7def2410c8d2 (patch)
tree0a63d6f3a38e40b03b9e02381cd1af0e622b45e1 /src/web.rs
parentfix(main): wait for geckodriver to be killed (diff)
downloadrin-main.tar.xz
rin-main.zip
feat(web): use any open portHEADmain
Diffstat (limited to 'src/web.rs')
-rw-r--r--src/web.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/web.rs b/src/web.rs
index eb10ff2..1fa8a27 100644
--- a/src/web.rs
+++ b/src/web.rs
@@ -1,20 +1,21 @@
use {thirtyfour::WebDriver, tokio::process::Command};
-pub fn geckodriver() -> Result<tokio::process::Child, std::io::Error> {
+pub fn geckodriver(port: u16) -> Result<tokio::process::Child, std::io::Error> {
Command::new("geckodriver")
- .arg("--port=9515")
+ .arg(format!("--port={port}"))
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.spawn()
}
-pub async fn webdriver() -> Result<WebDriver, thirtyfour::error::WebDriverError>
-{
+pub async fn webdriver(
+ port: u16,
+) -> Result<WebDriver, thirtyfour::error::WebDriverError> {
let mut caps = thirtyfour::DesiredCapabilities::firefox();
caps.set_headless().expect("failed to set headless");
- let driver = WebDriver::new("http://localhost:9515", caps)
+ let driver = WebDriver::new(&format!("http://localhost:{port}"), caps)
.await
.expect("failed to connect to webdriver");