I’m running Arch Linux with current chromium browser version (80.0.3987.100-1) and all packages fully updated.
I have a python script that requires chromedriver. The instructions there say,
- ChromeDriver is a separate executable
- Help WebDriver find the downloaded ChromeDriver executable by specifying the path
- [python] driver = webdriver.Chrome(‘/path/to/chromedriver’)
In chromium, chromedriver is included (at least on Arch, and probably on all distros):
/usr/lib/chromium/chromedriver
I have a simple question. When using chromium, is it necessary to provide a path to chromedriver, as in the example below?
driver = webdriver.Chrome(executable_path="/usr/lib/chromium/chromedriver",options=chromeOptions)
I see from the instructions that if the path is not provided explicitly, it will search. But I wish to avoid searching multiple paths and I want to avoid any chance of runtime errors due to chromedriver not being found.
I would guess that because chromedriver and chromium are developed by the same team, and they are packaged together, I can avoid any problems without having to hard code the path. I will also see what works on my system, but I am looking for feedback based on actual real-world experience. I don’t want to encounter an error related to this when I deploy. My question is simply can anyone confirm that this will work correctly under the conditions above without the path?
EDIT: In response to a comment: This appears to be the documentation:
https://selenium.dev/selenium/docs/api/py/webdriver_chrome/selenium.webdriver.chrome.service.html
However, it does not mention what types of exceptions it throws. Furthermore, adding exception handling is not relevant to my question. The documentation states that this method will search if a path is not provided. I want to know if the first location searched is /usr/lib/chromium/chromedriver
. The documentation I found also does not address that.
I know this is a super simple question. Maybe it is too simple? If I can find the source code, I believe I can read it and learn the answer. However, I asked in part so that I would not have to spend hours trying to figure out the answer for myself.
Advertisement
Answer
I am no authority on this but when checking the github source code for selenium, one can see that the default value for executable_path
(which is deprecated in their repo by the way) is just chromedriver
(Line 34 in webdriver.Chrome).
It then just runs this command per subprocess. This means only the paths in the environment variable $PATH
will be search through. Selenium does not carry out any search by themselves.
You can read here, how you can add the path to your chromium webdriver to the environment variable.