thirtyfour
thirtyfour copied to clipboard
Feature: Create WebDriverManager for starting and stopping local webdriver servers (and more)
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.
I'm not clear on what the issue is here.
- Are you suggesting that this library should take care of starting and stopping the chromedriver binary? What about other browsers?
- 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.
Please, transform in a feature, something like webdriver_manager module of python should be awesome, because it not only download chromedriver, also keep updated according to user chrome version. All APIs of selenium in other languages manage driver binary as I know. Thank you.
Obter o Outlook para Androidhttps://aka.ms/AAb9ysg
From: Steve Pryde @.> Sent: Sunday, July 3, 2022 7:29:45 AM To: stevepryde/thirtyfour @.> Cc: 520Pig520 @.>; Author @.> Subject: Re: [stevepryde/thirtyfour] I have to start chromedriver server with another function, but could be not necessary (Issue #99)
I'm not clear on what the issue is here.
- Are you suggesting that this library takes care of starting and stopping the chromedriver binary? What about other browsers?
- 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.
— Reply to this email directly, view it on GitHubhttps://github.com/stevepryde/thirtyfour/issues/99#issuecomment-1173055095, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIGFGP6T666W7FGEV2LR66TVSFTRTANCNFSM5ZI5Y3QA. You are receiving this because you authored the thread.Message ID: @.***>
I never thought of making it automatically download the latest version of chromedriver
or geckodriver
. I like that idea.
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.
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.
@stevepryde may it help you? https://crates.io/crates/webdriver-install The feature indeed would be nice to have!
Definitely!
There's another aspect which is managing the life cycle of the webdriver etc.
Thanks for letting me know about this 😊
See also #127
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
@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).
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.