Search code examples
pythonselenium-webdriverselenium-chromedriverwebdriver

WARNING:root:Can not find chromedriver for currently installed chrome version


I use selenium in my python project. Few days ago program worked correctly but today I ran my script and it caused this warning. Script:

from selenium import webdriver
import chromedriver_autoinstaller


chromedriver_autoinstaller.install()
options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications": 1}

options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')

options.add_experimental_option("prefs", prefs)
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
driver = webdriver.Chrome(options=options)
driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
driver.execute_cdp_cmd("Network.setUserAgentOverride", {"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"})

I tried reinstall chromedriver but it didn't help


Solution

  • Selenium Manager is now fully included with selenium 4.10.0, so this is all you need:

    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service
    
    service = Service()
    options = webdriver.ChromeOptions()
    driver = webdriver.Chrome(service=service, options=options)
    # ...
    driver.quit()
    

    If the driver isn't found on your system PATH, Selenium Manager will automatically download it.


    If you're wondering why you're now seeing this error, it's because https://chromedriver.chromium.org/downloads only goes up to version 114 due to driver restructuring by the Chromium Team for the new Chrome-for-Testing.