Before instantiating a new undetected-chromedriver - instance, I ensure that the latest ChromeDriver version is installed via the python-chromedriver-autoinstaller library as mentioned in this post:
import chromedriver_autoinstaller
chromedriver_autoinstaller.install()
'C:\\Users\\username\\project_path\\lib\\site-packages\\chromedriver_autoinstaller\\106\\chromedriver.exe'
As can be seen, it automatically installs version 106, but in the error message (caused by the intent to instantiate the undetected Chrome Driver via UndetectedChromeDriver.Chrome(options=self._browser_options)
), it states I need the next version 107:
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:... from session not created: This version of ChromeDriver only supports Chrome version 107 Current browser version is 106.0.5249.119
Another conventional way of automatically installing the required chromedriver did not work either:
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
import undetected_chromedriver as UndetectedChromeDriver
return UndetectedChromeDriver.Chrome(
options=self._browser_options,
service=ChromeService(ChromeDriverManager().install()))
I need to deploy this remotely, so there should be a way to automatically get and install the required ChromeDriver - version.
The full error message with traceback is as follows:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\username\project_path\lib\site-packages\undetected_chromedriver\__init__.py", line 103, in __init__
def __init__(
File "C:\Users\username\project_path\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 35, in __init__
def __init__(self, executable_path=DEFAULT_EXECUTABLE_PATH, port=DEFAULT_PORT,
File "C:\Users\username\project_path\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 37, in __init__
def __init__(self, browser_name, vendor_prefix,
File "C:\Users\username\project_path\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 195, in __init__
def __init__(self, command_executor='http://127.0.0.1:4444',
File "C:\Users\username\project_path\lib\site-packages\undetected_chromedriver\__init__.py", line 599, in start_session
def start_session(self, capabilities=None, browser_profile=None):
File "C:\Users\username\project_path\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 346, in start_session
def start_session(self, capabilities: dict, browser_profile=None) -> None:
File "C:\Users\username\project_path\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 408, in execute
def execute(self, driver_command: str, params: dict = None) -> dict:
File "C:\Users\username\project_path\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 102, in check_response
def check_response(self, response: Dict[str, Any]) -> None:
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:...
from session not created: This version of ChromeDriver only supports Chrome version 107
Current browser version is 106.0.5249.119
Stacktrace:
Backtrace:
Ordinal0 [0x00FEACD3+2075859]
Ordinal0 [0x00F7EE61+1633889]
Ordinal0 [0x00E7B7BD+571325]
Ordinal0 [0x00E9DFCD+712653]
Ordinal0 [0x00E96D24+683300]
Ordinal0 [0x00E96B01+682753]
Ordinal0 [0x00ECDBD3+908243]
Ordinal0 [0x00ECD6AA+906922]
Ordinal0 [0x00EC7136+880950]
Ordinal0 [0x00E9FEFD+720637]
Ordinal0 [0x00EA0F3F+724799]
GetHandleVerifier [0x0129EED2+2769538]
GetHandleVerifier [0x01290D95+2711877]
GetHandleVerifier [0x0107A03A+521194]
GetHandleVerifier [0x01078DA0+516432]
Ordinal0 [0x00F8682C+1665068]
Ordinal0 [0x00F8B128+1683752]
Ordinal0 [0x00F8B215+1683989]
Ordinal0 [0x00F96484+1729668]
BaseThreadInitThunk [0x774CFA29+25]
RtlGetAppContainerNamedObjectPath [0x779E7BBE+286]
RtlGetAppContainerNamedObjectPath [0x779E7B8E+238]
EDIT (more info about Chrome Version):
C:\Users\username>REG QUERY HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon /v Version
HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon
Version REG_SZ 106.0.5249.119