diff options
| author | Fuwn <[email protected]> | 2024-01-12 17:23:28 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-12 17:23:28 -0800 |
| commit | 83284cd99bc77232e934c0eb505b7def2410c8d2 (patch) | |
| tree | 0a63d6f3a38e40b03b9e02381cd1af0e622b45e1 /src/web.rs | |
| parent | fix(main): wait for geckodriver to be killed (diff) | |
| download | rin-main.tar.xz rin-main.zip | |
Diffstat (limited to 'src/web.rs')
| -rw-r--r-- | src/web.rs | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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"); |