diff options
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"); |