Search code examples
python-3.xgoogle-chromeselenium-webdriverwebdriver-managerwebdrivermanager-python

Selenium ChromeDriverManager doesn't downloads the latest version of ChromeDriver


I have an error:

E       selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 102
E       Current browser version is 109.0.5414.120 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

I have already used the code to get latest version of webdriver-

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
options = webdriver.ChromeOptions()
options.add_argument("--allow-running-insecure-content")
options.add_argument("--ignore-certificate-errors")
options.set_capability("acceptInsecureCerts", True)

        preferences = {"profile.default_content_settings.popups": 0,
                       "download.default_directory": r""+Constants.path+"",
                       # IMPORTANT - ENDING SLASH V IMPORTANT
                       "directory_upgrade": True}
options.add_experimental_option("prefs", preferences)

driver = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options)

With this same code I am able to run this code on my local machine(i.e. laptop) but this code is not working on my Virtual machine. the chrome version on both machine is same i.e. - 109.0.5414.120.

Please guide.


Solution

  • On my virtual machine, I found that there are two different versions(one latest and one older version) of chrome installed at two different locations. Therefore I uninstalled both chrome and deleted all chrome/google associated folders and files then install a fresh version of the google chrome browser. Finally, the code runs successfully.