ChromeDriverManager().install() doesn't work. (WebDriver manager)
Asked Answered
H

3

7

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.

Heterocyclic answered 5/7, 2022 at 10:57 Comment(0)
B
16

May be your web driver manager is outdated.


Uninstall your web driver manager by...

pip uninstall webdriver_manager   

...then again install...

pip install webdriver_manager

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/')
Bly answered 5/7, 2022 at 12:53 Comment(4)
Where does it install the ChromeDriver then on the linux/ubuntu? Is there a way to find it out?Reid
@VikasGoel On macos it is in ~/.wdmIncomprehensive
On Linux, it is also ~/.wdmCrossly
Just an extra note (for those fixing legacy code - like me) - From Selinium 3 to Selinium 4, there was a change in how WebDriver-Manager's initialization is conducted - as shown in the answer.Darien
R
0

Maybe your webdriver manager is outdated. Uninstall webdriver_manager:

pip uninstall webdriver_manager  

Then install again:

pip install webdriver_manager 

And install selenium:

pip install selenium 
Romulus answered 30/8, 2023 at 21:9 Comment(0)
F
0

I got the answer from https://gemini.google.com

The issue was using driver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options)

Google gemini said:

Since ChromeDriverManager().install() already returns the path to the ChromeDriver executable, there's no need to pass it as the first argument. Simply remove it:

Python

driver = webdriver.Chrome(options=chrome_options)

I replaced driver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options)

With driver = webdriver.Chrome(options=chrome_options) and it worked again.

Floyfloyd answered 30/7 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.