10

This is my code. I am doing it this way because when I tried to put a path to chromedriver.exe, I was either getting "WebDriverException: Message: 'chromedriver.exe' executable may have wrong permissions" or "WebDriverException: Message: 'chromedriver' executable needs to be in PATH" and I could not figure out how to fix it.

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager


browser = webdriver.Chrome(ChromeDriverManager().install())

Running this code gives the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-43-614c8d8b619c> in <module>
      5 
      6 
----> 7 browser = webdriver.Chrome(ChromeDriverManager().install())
      8 

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/chrome.py in install(self, path)
     17     def install(self, path=None):
     18         # type: () -> str
---> 19         bin_file = self._file_manager.download_driver(self.driver, path)
     20         os.chmod(bin_file.path, 0o755)
     21         return bin_file.path

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/cache.py in download_driver(self, driver, path, subpath)
     70         if path is not None:
     71             path = os.path.abspath(path)
---> 72         cached_binary = self.get_cached_binary(driver, path, subpath)
     73         if cached_binary:
     74             return cached_binary

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/cache.py in get_cached_binary(self, driver, path, subpath)
     36 
     37         name = driver.name
---> 38         version = driver.get_version()
     39         os_type = driver.os_type
     40         console("")

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/driver.py in get_version(self)
     32         # type: () -> str
     33         if self._version == "latest":
---> 34             return self.get_latest_release_version()
     35         return self._version
     36 

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/driver.py in get_latest_release_version(self)
     48         # type: () -> str
     49         resp = requests.get(
---> 50             self.config.driver_latest_release_url + '_' + chrome_version()
     51         )  # returns chromedriver version for current browser version
     52         validate_response(self, resp)

/srv/conda/envs/notebook/lib/python3.7/site-packages/webdriver_manager/utils.py in chrome_version()
     60     if not version:
     61         raise ValueError(
---> 62             'Could not get version for Chrome with this command: {}'.format(cmd)
     63         )
     64     return version.group(0)

ValueError: Could not get version for Chrome with this command: google-chrome --version

I have absolutely no clue what I can do to fix this, honestly.

Newskooler
  • 3,973
  • 7
  • 46
  • 84
  • Did you manage to solve this? – Newskooler Jun 04 '20 at 03:58
  • I just installed the Chrome driver manually and referenced the executable path`browser = webdriver.Chrome(executable_path='chromedriver.exe')` –  Jun 04 '20 at 21:31
  • So you are not using webdriver_manager at all then? – Newskooler Jun 04 '20 at 21:35
  • Yeah, looking at my code, I apparently fixed the problem I described in this question where I said that I couldn't put a path to chromedriver.exe, leaving me with no need for webdriver_manager. Unfortunately, I don't recall how exactly I fixed that. –  Jun 04 '20 at 21:37
  • The way you describe it, you did not fix it, but rather removed it. The idea of webdriver_manager it to use without manually installing and pointing to the webdriver. That's how I understand it. – Newskooler Jun 04 '20 at 21:38
  • 1
    In the body of my question, I said that when I tried to put a path to chromedriver.exe, I was given an error message, which is why I used webdriver_manager. I fixed _that_ problem, leaving me with no need to figure out why I couldn't use webdriver_manager. But it is true that the problem that is the subject of this question was never fixed. –  Jun 04 '20 at 21:41

3 Answers3

3

It is a bug in webdriver_manager link.

To avoid this issue you can use google-chrome-stable browser instead of chromium-browser.

Overchenko
  • 71
  • 3
1

That is because you have not mentioned the chrome type. use the following code

from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType


    browser = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.GOOGLE).install())
Soumya
  • 187
  • 1
  • 6
  • 6
    This doesn't work for me either... I get a message : ValueError: Could not get version for Chrome with this command: google-chrome --version || google-chrome-stable --version – J.A Dec 16 '20 at 22:27
1

A bit late to answer but may be you are missing packages like in my case I was missing build packs on Heroku.

heroku buildpacks:add heroku/chromedriver

heroku buildpacks:add heroku/google-chrome

After this, do an empty commit and redeploy:

git commit --allow-empty -m "Empty Commit"

git push heroku master

Maisum Abbas
  • 317
  • 1
  • 10
  • 1
    The only important part here, for me, was the redeploy with emtpy commit. I was only restarting dyno `heroku restart` and it needed a rebuild. I don't know how to build w/o commit, and adding buildpack only, w/ no other changes returns `Everything up-to-date` – Mote Zart Apr 27 '22 at 01:20