Making program using Chromedriver, getting error: “Could not get version for Chrome with this command”

独自空忆成欢 提交于 2020-06-12 07:46:47

问题


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.


回答1:


It is a bug in webdriver_manager link.

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



来源:https://stackoverflow.com/questions/57175675/making-program-using-chromedriver-getting-error-could-not-get-version-for-chr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!