ChromeDriverManager().install() doesn't work. (WebDriver manager)

Issue

I tried code below in TEST.py:32

print("ChromeDriverManager().install() :", ChromeDriverManager().install())
[WDM] - ====== WebDriver manager ======
2022-07-05 19:49:04,445 INFO ====== WebDriver manager ======
Traceback (most recent call last):
  File "d:\Python\PYTHONWORKSPACE\repo\Auto-booking-master\src\TEST.py", line 32, in <module>
    print("ChromeDriverManager().install() :", ChromeDriverManager().install())
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\webdriver_manager\chrome.py", line 38, in install
    driver_path = self._get_driver_path(self.driver)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\webdriver_manager\core\manager.py", line 29, in _get_driver_path
    binary_path = self.driver_cache.find_driver(driver)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\webdriver_manager\core\driver_cache.py", line 95, in find_driver
    driver_version = driver.get_version()
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\webdriver_manager\core\driver.py", line 43, in get_version
    self.get_latest_release_version()
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\webdriver_manager\drivers\chrome.py", line 37, in get_latest_release_version
    self.browser_version = get_browser_version_from_os(self.chrome_type)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\webdriver_manager\core\utils.py", line 152, in get_browser_version_from_os  
    cmd_mapping = {
KeyError: 'google-chrome'

Please help me.

Solution

Install webdriver-manager:

pip install webdriver-manager, pip install selenium

And then:

# selenium 4
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

option = webdriver.ChromeOptions()
option.add_argument("start-maximized")


driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=option)
driver.get('https://www.google.com/')

WebDriverManager

Answered By – F.Hoque

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published