SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.16k stars 8.1k forks source link

[🐛 Bug]:ChromeDriverManager picking Incorrect File (THIRD_PARTY_NOTICES.chromedriver) Instead of chromedriver.exe to install chromedriver version(127.0.6533.72) #14312

Closed Raghuramrwttw closed 1 month ago

Raghuramrwttw commented 1 month ago

What happened?

I am encountering an issue with the ChromeDriverManager when trying to install chromedriver for Chromelatest version 127.0.6533.72. The ChromeDriverManager is incorrectly picking up the THIRD_PARTY_NOTICES.chromedriver file instead of the chromedriver.exe file. This issue does not occur with older versions of ChromeDriver.

How can we reproduce the issue?

import subprocess
import re
import os
import shutil
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.core.os_manager import ChromeType
from webdriver_manager.chrome import ChromeDriverManager

# Clear the webdriver_manager cache
cache_path = os.path.expanduser("~/.wdm")
if os.path.exists(cache_path):
    shutil.rmtree(cache_path)

# Possible paths for Chrome
chrome_paths = [
    r"C:\Program Files\Google\Chrome\Application\chrome.exe",
    r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
]

# Function to get the Chrome version
def get_chrome_version():
    version = None
    for path in chrome_paths:
        if os.path.exists(path):
            try:
                output = subprocess.check_output([path, '--version'], shell=True).decode('utf-8')
                version = re.search(r'(\d+\.\d+\.\d+\.\d+)', output).group(1)
                break
            except Exception as e:
                print(f"Error getting Chrome version from {path}: {e}")
    if not version:
        # Fallback to checking Windows registry
        try:
            output = subprocess.check_output(
                'reg query "HKEY_CURRENT_USER\\Software\\Google\\Chrome\\BLBeacon" /v version', 
                shell=True
            ).decode('utf-8')
            version = re.search(r'version\s+REG_SZ\s+(\d+\.\d+\.\d+\.\d+)', output).group(1)
        except Exception as e:
            print(f"Error getting Chrome version from registry: {e}")
    return version

chrome_version = get_chrome_version()
if chrome_version:
    print(f"Detected Chrome version: {chrome_version}")
    driver_manager = ChromeDriverManager(chrome_type=ChromeType.GOOGLE)
    driver_path = driver_manager.install()
    print(f"Using ChromeDriver at: {driver_path}")
    options = webdriver.ChromeOptions()
    service = Service(driver_path)
    authdriver = webdriver.Chrome(service=service, options=options)

    # Print the ChromeDriver version
    chrome_driver_version = authdriver.capabilities['chrome']['chromedriverVersion'].split(' ')[0]
    print(f"ChromeDriver version: {chrome_driver_version}")

    # Your code to interact with the browser here
    authdriver.quit()
else:
    print("Could not determine Chrome version. Please ensure Chrome is installed.")

try with latest verison of Chrome(127.0.6533.72) to reproduce this issue.

Relevant log output

2024-07-26 11:00:17,041 - INFO - Get LATEST chromedriver version for google-chrome
2024-07-26 11:00:17,041 - INFO - Get LATEST chromedriver version for google-chrome
2024-07-26 11:00:17,041 - DEBUG - Starting new HTTPS connection (1): googlechromelabs.github.io:443
2024-07-26 11:00:17,041 - DEBUG - Starting new HTTPS connection (1): googlechromelabs.github.io:443
2024-07-26 11:00:17,088 - DEBUG - https://googlechromelabs.github.io:443 "GET /chrome-for-testing/latest-patch-versions-per-build.json HTTP/1.1" 200 6461
2024-07-26 11:00:17,088 - DEBUG - https://googlechromelabs.github.io:443 "GET /chrome-for-testing/latest-patch-versions-per-build.json HTTP/1.1" 200 6461
2024-07-26 11:00:17,104 - DEBUG - Starting new HTTPS connection (1): googlechromelabs.github.io:443
2024-07-26 11:00:17,104 - DEBUG - Starting new HTTPS connection (1): googlechromelabs.github.io:443
2024-07-26 11:00:17,135 - DEBUG - https://googlechromelabs.github.io:443 "GET /chrome-for-testing/known-good-versions-with-downloads.json HTTP/1.1" 200 50018
2024-07-26 11:00:17,135 - DEBUG - https://googlechromelabs.github.io:443 "GET /chrome-for-testing/known-good-versions-with-downloads.json HTTP/1.1" 200 50018
2024-07-26 11:00:17,151 - INFO - WebDriver version 127.0.6533.72 selected
2024-07-26 11:00:17,151 - INFO - WebDriver version 127.0.6533.72 selected
2024-07-26 11:00:17,166 - INFO - Modern chrome version https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.72/win32/chromedriver-win32.zip
2024-07-26 11:00:17,166 - INFO - Modern chrome version https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.72/win32/chromedriver-win32.zip
2024-07-26 11:00:17,166 - INFO - About to download new driver from https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.72/win32/chromedriver-win32.zip
2024-07-26 11:00:17,166 - INFO - About to download new driver from https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.72/win32/chromedriver-win32.zip
2024-07-26 11:00:17,166 - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
2024-07-26 11:00:17,166 - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
2024-07-26 11:00:17,198 - DEBUG - https://storage.googleapis.com:443 "GET /chrome-for-testing-public/127.0.6533.72/win32/chromedriver-win32.zip HTTP/1.1" 200 7757078
2024-07-26 11:00:17,198 - DEBUG - https://storage.googleapis.com:443 "GET /chrome-for-testing-public/127.0.6533.72/win32/chromedriver-win32.zip HTTP/1.1" 200 7757078
2024-07-26 11:00:17,198 - INFO - Driver downloading response is 200
2024-07-26 11:00:17,198 - INFO - Driver downloading response is 200
2024-07-26 11:00:17,276 - INFO - Get LATEST chromedriver version for google-chrome
2024-07-26 11:00:17,276 - INFO - Get LATEST chromedriver version for google-chrome
2024-07-26 11:00:17,276 - DEBUG - Starting new HTTPS connection (1): googlechromelabs.github.io:443
2024-07-26 11:00:17,276 - DEBUG - Starting new HTTPS connection (1): googlechromelabs.github.io:443
2024-07-26 11:00:17,307 - DEBUG - https://googlechromelabs.github.io:443 "GET /chrome-for-testing/latest-patch-versions-per-build.json HTTP/1.1" 200 6461
2024-07-26 11:00:17,307 - DEBUG - https://googlechromelabs.github.io:443 "GET /chrome-for-testing/latest-patch-versions-per-build.json HTTP/1.1" 200 6461
2024-07-26 11:00:17,635 - INFO - Driver has been saved in cache [C:\Users\deavalid\.wdm\drivers\chromedriver\win64\127.0.6533.72]
2024-07-26 11:00:17,635 - INFO - Driver has been saved in cache [C:\Users\deavalid\.wdm\drivers\chromedriver\win64\127.0.6533.72]
2024-07-26 11:00:17,651 - DEBUG - Skipping Selenium Manager; path to chrome driver specified in Service class: C:\Users\deavalid\.wdm\drivers\chromedriver\win64\127.0.6533.72\chromedriver-win32/THIRD_PARTY_NOTICES.chromedriver

Operating System

windows server 2019

Selenium version

Version: 4.20.0

What are the browser(s) and version(s) where you see this issue?

Chrome latest version: 127.0.6533.72

What are the browser driver(s) and version(s) where you see this issue?

Chromedriver: 127.0.6533.72

Are you using Selenium Grid?

No response

github-actions[bot] commented 1 month ago

@Raghuramrwttw, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

diemol commented 1 month ago

ChromeDriverManager is not managed by Selenium. Please reach out to them.

We recommend Selenium Manager.

MrAkshay143 commented 1 month ago

Fixed:

Renamed THIRD_PARTY_NOTICES.chromedriver to THIRD_PARTY_NOTICES.chromedriver.exe in C:\Users\%username%\.wdm\drivers\chromedriver\win64\127.0.6533.72\chromedriver-win32. This resolves the issue.

lwolf123 commented 1 month ago

I had a similar issue this month. A python selenium job I run once at the beginning of each month blew up.

service = ChromeService(ChromeDriverManager().install())

now returns a chromedriver.exe path beginning with THIRD_PARTY_NOTICES, which does not exist on my system. This did not happen last month.

So instead of that statement I have these four statements and the job works again, for now..

chrome_install = ChromeDriverManager().install() folder = os.path.dirname(chrome_install) chromedriver_path = os.path.join(folder, "chromedriver.exe") service = ChromeService(chromedriver_path)

github-actions[bot] commented 5 days ago

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.