From my knowledge, there are two ways to use a chrome driver with selenium in python:
either by downloading the chromedriver.exe, then by integrating it into the parameter:
browser = webdriver.Chrome(executable_path=r"C:\path\to\chromedriver.exe")
either by installing chromedriver_binary via
pip install chromedriver-binary
, in this case no more need to configure the instantiation of chrome driverbrowser = webdriver.Chrome ()
My question is which is the most efficient method in terms of execution time? Which of these two methods do you recommend?
Thank you
CodePudding user response:
chromedriver-binary
chromedriver-binary downloads and installs the chromedriver binary version 97.0.4692.36 for automated testing of webapps. The installer supports Linux, MacOS and Windows operating systems.
To install:
pip install chromedriver-binary
Usage: To use chromedriver you need the following import:
import chromedriver_binary
This will add the executable to your PATH so it will be found. You can also get the absolute filename of the binary using:
chromedriver_binary.chromedriver_filename
However with Selenium v3.x you can download the ChromeDriver and use the key executable_path
to pass the absolute path of the ChromeDriver.
browser = webdriver.Chrome(executable_path=r"C:\path\to\chromedriver.exe")
Conclusion
There is no best practices defined neither any efficiency matrix comparing the two approaches. It's the user perspective of comfortness. The only bonus point using executable_path
is, you don't require to install any additional package.