Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Create WebDriverManager for starting and stopping local webdriver servers (and more) #99

Open
BornSaint opened this issue Jun 20, 2022 · 11 comments
Labels
enhancement New feature or request

Comments

@BornSaint
Copy link

BornSaint commented Jun 20, 2022

fn run_chromedriver(path: String) -> std::process::Child{
    let output = 
        std::process::Command::new(&path)
        .arg("--ip=localhost")
        .arg("--port=4444")
        .spawn()
        .expect("Command failed");
    return output
}

I'm using this function to start chromedriver, passing a path to it as parameter, but if you have use other selenium bindings, this is the common use. Pass the ip address for webdriver force the user to start by command line the chromedriver executable for example.
I'm calling the above function this way:

let mut chromedriver = run_chromedriver(String::from("./34_drivers/chromedriver"));

and the latest lines are:

    driver.quit().await?;
    chromedriver.kill().expect("chromedriver server process not killed, do manually"); 
    Ok(())

I'm doing it because driver.quit() don't kill the session and chromedriver process still running after program has finished. Sometimes, the browser doesn't open, and the prompt say the output of chromedriver executable (chromedriver was started successfully whatever) and the next lines to exit never are executed, so the program run forever doing nothing, like stucked in while loop.

@stevepryde
Copy link
Owner

stevepryde commented Jul 3, 2022

I'm not clear on what the issue is here.

  1. Are you suggesting that this library should take care of starting and stopping the chromedriver binary? What about other browsers?
  2. Or are you referring to the issue of the WebDriver session not being stopped correctly?

As for (1), this has not been a goal of this project so far, but I can see how it could be useful especially for running on your local machine during development. However, one issue with running chromedriver locally like this is that the browser will steal keyboard input focus depending on what you do, and will also be brought in front of other applications if you take a screenshot via automation, which isn't ideal if you want to keep working while the browser is running. I would strongly recommend using docker to run the browser, as per the README. You can view the browser in-flight using VNC.
If you do want thirtyfour to manage its own chromedriver instance, let me know. That would transform this ticket into a feature request, and we can discuss how that feature should work in the case of chromedriver and geckodriver. I would be happy to limit support to just those two.

For (2), this would be a bug if driver.quit().await did indeed not close the session. I will test this further to confirm.
Btw, closing the WebDriver session will not terminate chromedriver itself. That is not what that API call does.

@stevepryde stevepryde added the question Further information is requested label Jul 3, 2022
@BornSaint
Copy link
Author

BornSaint commented Jul 3, 2022 via email

@stevepryde
Copy link
Owner

I never thought of making it automatically download the latest version of chromedriver or geckodriver. I like that idea.

@stevepryde stevepryde changed the title I have to start chromedriver server with another function, but could be not necessary Feature: Create WebDriverManager for starting and stopping local webdriver servers (and more) Jul 31, 2022
@stevepryde
Copy link
Owner

I've updated this issue to be for the following features:

  • Create WebDriverManager to manage local webdriver servers (start, stop, etc)
  • Automatically download latest chromedriver or geckodriver if not present
  • Option to automatically update to the latest chromedriver or geckodriver if the current one is outdated

The webdriver download parts may be split out into a separate issue.

@stevepryde stevepryde added enhancement New feature or request and removed question Further information is requested labels Jul 31, 2022
@stevepryde
Copy link
Owner

For reference: https://pypi.org/project/webdriver-manager/
Something like this would be cool.

Also, I think this should probably be a separate crate+repo since it would be useful for fantoccini as well.

@MontolioV
Copy link

@stevepryde may it help you?
https://crates.io/crates/webdriver-install
The feature indeed would be nice to have!

@stevepryde
Copy link
Owner

Definitely!

There's another aspect which is managing the life cycle of the webdriver etc.

Thanks for letting me know about this 😊

@stevepryde
Copy link
Owner

See also #127

@stevepryde
Copy link
Owner

For now I would direct people to use Selenium Manager. It can be used as a lib crate.
https://github.com/SeleniumHQ/selenium/tree/trunk/rust

Also see: https://github.com/stevepryde/thirtyfour#using-selenium-manager

@cloud303-cholden
Copy link

@stevepryde I noticed that your second link isn't in the readme anymore. Do you still recommend using Selenium Manager or is there a better way? I've been struggling with this myself, and am using a naive implementation in the meantime (link).

@stevepryde
Copy link
Owner

At this stage I still have not actually used Selenium-manager because it's not easy to build and to my knowledge the binaries are not hosted anywhere. I had planned to maintain a mirror of it that gets pushed to crates.io but that might be more work than I have time for.

The advantage is that it's an official tool so it should be well supported, hopefully.

That said, it isn't practical to use. I prefer using the Selenium docker images personally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants