3

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.

9
  • Why not actually handle the error? If the method raises an Exception, use try/except and retry with (or without) the path. You can make a list of possibilities and try each one until success. Commented Feb 13, 2020 at 0:15
  • @stolenmoment - well, I have not been able to find the documentation on that initialization method. Commented Feb 13, 2020 at 1:04
  • Experiment! Feed it a bogus path and see what happens. Feed it a good path and see what's different. Commented Feb 13, 2020 at 1:56
  • @stolenmoment - I mentioned exactly this in the question. Furthermore, I believe it is always better to ask an authority rather than to deploy something based on trial & error experimentation in one person's environment. If the answer to every question was "experiment" there would be almost zero need for Stack Exchange. This is a super simple question. I only asked because I did not want to base my decision on experimenting on my environment. Commented Feb 13, 2020 at 2:33
  • 1
    Expertise is created through experimenting. Also, I wouldn't call SE an 'authority' Commented Feb 13, 2020 at 8:16

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

FTR: it does search for chromedriver if there's selenium-manager installed. However, I personally couldn't make selenium-manager to compile in the short amount of time I had (it just fails with a error: linking with cc failed), so I instead I temporarily hardcoded the path as from selenium.webdriver.chrome.service import Service and webdriver.Chrome(options=options, service = Service('/usr/bin/chromedriver')) (not sure that warrants a separate answer, so posting as a comment).
-1

Using Selenium Chrome driver Python Arch Linux

Install chromium:

pacman -Syu
pacman -S chromium

Python:

from selenium import webdriver
self.browser = webdriver.Chrome()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.