SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.5k stars 8.15k forks source link

[🐛 Bug]: KeyError: 'google-chrome' - python selenium webdriver #10866

Closed stromal closed 2 years ago

stromal commented 2 years ago

What happened?

GOAL

Tried to solve by

How can we reproduce the issue?

# MY CODE

# selenium 3
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())
# selenium 4
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))

### Relevant log output

```shell
# ERROR 

[WDM] - ====== WebDriver manager ======
2022-07-11 15:49:01,250 INFO ====== WebDriver manager ======
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-18-0987a487086c> in <module>
      2 from webdriver_manager.chrome import ChromeDriverManager
      3 
----> 4 driver = webdriver.Chrome(ChromeDriverManager().install())

~/.local/lib/python3.8/site-packages/webdriver_manager/chrome.py in install(self)
     36 
     37     def install(self) -> str:
---> 38         driver_path = self._get_driver_path(self.driver)
     39         os.chmod(driver_path, 0o755)
     40         return driver_path

~/.local/lib/python3.8/site-packages/webdriver_manager/core/manager.py in _get_driver_path(self, driver)
     27 
     28     def _get_driver_path(self, driver):
---> 29         binary_path = self.driver_cache.find_driver(driver)
     30         if binary_path:
     31             return binary_path

~/.local/lib/python3.8/site-packages/webdriver_manager/core/driver_cache.py in find_driver(self, driver)
     93         os_type = driver.get_os_type()
     94         driver_name = driver.get_name()
---> 95         driver_version = driver.get_version()
     96         browser_version = driver.browser_version
     97 

~/.local/lib/python3.8/site-packages/webdriver_manager/core/driver.py in get_version(self)
     41     def get_version(self):
     42         self._version = (
---> 43             self.get_latest_release_version()
     44             if self._version == "latest"
     45             else self._version

~/.local/lib/python3.8/site-packages/webdriver_manager/drivers/chrome.py in get_latest_release_version(self)
     35 
     36     def get_latest_release_version(self):
---> 37         self.browser_version = get_browser_version_from_os(self.chrome_type)
     38         log(f"Get LATEST {self._name} version for {self.browser_version} {self.chrome_type}")
     39         latest_release_url = (

~/.local/lib/python3.8/site-packages/webdriver_manager/core/utils.py in get_browser_version_from_os(browser_type)
    150         return get_browser_version(browser_type, metadata)
    151 
--> 152     cmd_mapping = {
    153         ChromeType.BRAVE: {
    154             OSType.LINUX: linux_browser_apps_to_cmd(

KeyError: 'google-chrome'


### Operating System

aws ec2 ubuntu 20.04 LTS

### Selenium version

3.141.0

### What are the browser(s) and version(s) where you see this issue?

None it is in an aws ec2 jupyter notebook, desktop browser is Version 103.0.5060.114 (Official Build) (64-bit)

### What are the browser driver(s) and version(s) where you see this issue?

Version 103.0.5060.114 (Official Build) (64-bit)

### Are you using Selenium Grid?

no
github-actions[bot] commented 2 years ago

@stromal, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

diemol commented 2 years ago

From the stacktrace, it seems to be an error coming from https://github.com/SergeyPirogov/webdriver_manager. Could you please report it over there?

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.