Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChromeDriverManager picking Incorrect File (THIRD_PARTY_NOTICES.chromedriver) Instead of chromedriver.exe to install chromedriver for chrome version(127.0.6533.72) #670

Open
Raghuramrwttw opened this issue Jul 30, 2024 · 8 comments

Comments

@Raghuramrwttw
Copy link

Raghuramrwttw commented Jul 30, 2024

I am encountering an issue with the ChromeDriverManager when trying to install chromedriver for Chrome latest 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 Chrome.

Logs:
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
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
2024-07-26 11:00:17,682 - ERROR - An error occurred: cannot access local variable 'authdriver' where it is not associated with a value
2024-07-26 11:00:17,682 - ERROR - An error occurred: cannot access local variable 'authdriver' where it is not associated with a value
2024-07-26 11:00:17,776 - ERROR - Traceback (most recent call last):
File "D:\automate\src\EmailUtil.py", line 143, in get_access_token_from_GraphAPI
authdriver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\automate\v_311\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in init
super().init(
File "D:\automate\v_311\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 55, in init
self.service.start()
File "D:\automate\v_311\Lib\site-packages\selenium\webdriver\common\service.py", line 98, in start
self._start_process(self._path)
File "D:\automate\v_311\Lib\site-packages\selenium\webdriver\common\service.py", line 208, in _start_process
self.process = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\subprocess.py", line 1024, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\Python311\Lib\subprocess.py", line 1493, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 193] %1 is not a valid Win32 application

@AlineGobbi
Copy link

AlineGobbi commented Jul 30, 2024

on this issue #665

have this code and resolved the problem for me

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager

if driver_path:
        driver_name = driver_path.split('/')[-1]
        if driver_name != "chromedriver":
            driver_path = "/".join(driver_path.split('/')[:-1] + ["chromedriver.exe"])
            if '/' in driver_path:
                driver_path = driver_path.replace('/', '\\')
            os.chmod(driver_path, 0o755)
driver = webdriver.Chrome(service=ChromeService(driver_path))

@sevroauasmo
Copy link

same issue- this worked for me:

from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service

chrome_path = ChromeDriverManager().install()
if "THIRD_PARTY_NOTICES.chromedriver" in chrome_path:
    chrome_path = chrome_path.replace("THIRD_PARTY_NOTICES.chromedriver", "chromedriver")
s = Service(chrome_path)
driver = webdriver.Chrome(service=s)

@ahmedsafadii
Copy link

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have wrong permissions.

def __init__(self):
    logging.info("Initializing ChromeDriver.")
    options = Options()
    options.add_experimental_option("prefs", {'profile.managed_default_content_settings.javascript': 2})
    options.add_argument("--disable-javascript")
    options.add_argument('headless')
    options.add_argument('window-size=1x1')
    options.add_argument("disable-gpu")
    options.add_argument("--disable-gpu")
    chrome_path = ChromeDriverManager().install()
    if "THIRD_PARTY_NOTICES.chromedriver" in chrome_path:
        chrome_path = chrome_path.replace("THIRD_PARTY_NOTICES.chromedriver", "chromedriver")
    self.driver = webdriver.Chrome(service=ChromeService(chrome_path), options=options)
    logging.info("ChromeDriver initialized.")

same issue

@cortlepp
Copy link

cortlepp commented Aug 2, 2024

This Issue was resolved by #666 and released as 4.0.2.
So in order to resolve this you must upgrade webdriver_manager to 4.0.2 first, and delete the driver that was already installed and caused problems (in the case of the original author C:\Users\deavalid.wdm\drivers\chromedriver\win64\127.0.6533.72). webdriver_manager will then redownload the driver and find the correct executable this time.

@haoyang324
Copy link

This issue still exists on 4.0.2 on Ubuntu.

I have updated webdriver_manager to 4.0.2 and removed all files under /root/.wdm/drivers/chromedriver/linux64/ but still got the same issue.

OSError: [Errno 8] Exec format error: '/root/.wdm/drivers/chromedriver/linux64/129.0.6668.70/chromedriver-linux64/THIRD_PARTY_NOTICES.chromedriver'

@davidmartos96
Copy link

@haoyang324 I was able to fix this in 4.0.2. I believe your issue is that you need to delete the file .../.wdm/drivers.json, which caches the binary paths. It most likely has cached the wrong path and you will get that one regardless the library version.

@haoyang324
Copy link

Thank you @davidmartos96, I do have cache with THIRD_PARTY_NOTICES.

However, even after deleting the cache, it gets regenerated with the same content.

To fix it, I have to manually remove the THIRD_PARTY_NOTICES from binary_path in the below drivers.json. Anyway it works well now!

{
    "linux64_chromedriver_129.0.6668.100_for_129.0.6668": {
        "timestamp": "23/10/2024",
        "binary_path": "/root/.wdm/drivers/chromedriver/linux64/129.0.6668.100/chromedriver-linux64/THIRD_PARTY_NOTICES.chromedriver"
    }

@haoyang324
Copy link

Weird. I know you have the code below but the cache always reverted to the one with THIRD_PARTY_NOTICES.
It finally works normally after I uninstalled and reinstalled the webdriver manager.
if 'LICENSE' in f:
continue
if 'THIRD_PARTY' in f:
continue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants