pythongoogle-chromeselenium-webdriverundetected-chromedriver

selenium driver needs Chrome version 138


I had this Python script to interact with a site, not I can't run this on a virtual machine due to enterprise restrictions. Now to get by trying to run this on local laptop, and can't upgrade to chrome 138, again due to enterprise restriction.

ERROR: selenium.common.exceptions.SessionNotCreatedException: Message: session not created: cannot connect to chrome at xxx.0.0.1:xxxxx from session not created: This version of ChromeDriver only supports Chrome version 138 Current browser version is 137.0.7151.69

from selenium import webdriver
import undetected_chromedriver as uc
import time
from selenium.webdriver.common.by import By
import urllib

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-extensions")
web = uc.Chrome(options=chrome_options)
#web = uc.Chrome()

web.get('https://www....')

How can I get by and run Chrome v137 with this code?


Solution

  • If you have Chrome 137 installed and it is available on your PATH, and you want to use the appropriate ChromeDriver with it, you can set the browser_version property before instantiating Chrome:

    chrome_options = webdriver.ChromeOptions()
    chrome_options.browser_version = "137"
    driver = webdriver.Chrome(options=chrome_options)
    

    This will download ChromeDriver 137 and use it to launch your previously installed version 137 of Chrome.