async fn handle_selenium(
    file_path: Option<PathBuf>,
    flag: bool,
    mut rx: mpsc::Receiver<String>,
) -> Result<(), thirtyfour::error::WebDriverError> {
    use thirtyfour::prelude::*;
    use tokio::fs;

    if flag {
        if let Some(file_path) = file_path {
            let mut caps = DesiredCapabilities::chrome();
            caps.add_chrome_arg("--enable-automation")?;
            let driver = WebDriver::new("http://localhost:4444/wd/hub", &caps).await?;
            // driver.fullscreen_window().await?;
            let mut file_name = 1;
            let mut file_path = file_path.clone();
            file_path.push("screenshots");
            if fs::create_dir_all(&file_path).await.is_err() {
                return Err(thirtyfour::error::WebDriverError::FatalError(
                    "".to_string(),
                ));
            }

            while let Some(link) = rx.recv().await {
                if driver.get(link.as_str()).await.is_ok() {
                    let mut img_path = file_path.clone();
                    img_path.push(file_name.to_string());
                    let _ = driver.fullscreen_window().await;
                    let _ = driver.screenshot(&img_path).await;
                    file_name += 1;
                }
            }
            let _ = driver.quit().await;
        }
    }
    Ok(())
}
/// Function to handle selenium.
/// Uses the chrome/chromium browser for now.
Function to handle selenium.
Uses the chrome/chromium browser for now.
Function to handle selenium . Uses the chrome / chromium browser for now .
async fn handle_selenium(
    file_path: Option<PathBuf>,
    flag: bool,
    mut rx: mpsc::Receiver<String>,
) -> Result<(), thirtyfour::error::WebDriverError> {
    use thirtyfour::prelude::*;
    use tokio::fs;
    if flag {
        if let Some(file_path) = file_path {
            let mut caps = DesiredCapabilities::chrome();
            caps.add_chrome_arg("--enable-automation")?;
            let driver = WebDriver::new("http://localhost:4444/wd/hub", &caps).await?;
            // driver.fullscreen_window().await?;
            let mut file_name = 1;
            let mut file_path = file_path.clone();
            file_path.push("screenshots");
            if fs::create_dir_all(&file_path).await.is_err() {
                return Err(thirtyfour::error::WebDriverError::FatalError(
                    "".to_string(),
                ));
            }
            while let Some(link) = rx.recv().await {
                if driver.get(link.as_str()).await.is_ok() {
                    let mut img_path = file_path.clone();
                    img_path.push(file_name.to_string());
                    let _ = driver.fullscreen_window().await;
                    let _ = driver.screenshot(&img_path).await;
                    file_name += 1;
                }
            }
            let _ = driver.quit().await;
        }
    }
    Ok(())
}
async fn handle_selenium ( file_path : Option < PathBuf > , flag : bool , mut rx : mpsc :: Receiver < String > , ) -> Result < ( ) , thirtyfour :: error :: WebDriverError > { use thirtyfour :: prelude :: * ; use tokio :: fs ; if flag { if let Some ( file_path ) = file_path { let mut caps = DesiredCapabilities :: chrome ( ) ; caps . add_chrome_arg ( " " ) ? ; let driver = WebDriver :: new ( " " , & caps ) . await ? ; // driver.fullscreen_window().await?; let mut file_name = 1 ; let mut file_path = file_path . clone ( ) ; file_path . push ( " " ) ; if fs :: create_dir_all ( & file_path ) . await . is_err ( ) { return Err ( thirtyfour :: error :: WebDriverError :: FatalError ( " " . to_string ( ) , ) ) ; } while let Some ( link ) = rx . recv ( ) . await { if driver . get ( link . as_str ( ) ) . await . is_ok ( ) { let mut img_path = file_path . clone ( ) ; img_path . push ( file_name . to_string ( ) ) ; let _ = driver . fullscreen_window ( ) . await ; let _ = driver . screenshot ( & img_path ) . await ; file_name += 1 ; } } let _ = driver . quit ( ) . await ; } } Ok ( ( ) ) }
Function to handle selenium.
Function to handle selenium .
file_path
Option<PathBuf>
flag
bool
rx
mpsc::Receiver<String>
file_path
Option<PathBuf>
flag
bool
rx
mpsc::Receiver<String>