SergeyPirogov / webdriver_manager

Apache License 2.0
2.06k stars 460 forks source link

cannot instance chromedriver in Version 127.0.6533.73 #664

Open ManuelSalaz opened 4 months ago

ManuelSalaz commented 4 months ago
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
chrome_service = ChromeService(ChromeDriverManager().install())
driver = webdriver.Chrome(service=chrome_service)

Console Output: OSError: [WinError 193] %1 is not a valid Win32 application

7r5 commented 4 months ago

I have the same issue, but using python I got this error: HOOK-ERROR in before_scenario: OSError: [Errno 8] Exec format error: '/root/.wdm/drivers/chromedriver/linux64/127.0.6533.72/chromedriver-linux64/THIRD_PARTY_NOTICES.chromedriver'

rozon commented 4 months ago

I'm having the same issue on mac: HOOK-ERROR in before_scenario: OSError: [Errno 8] Exec format error: '/Users/rozon/.wdm/drivers/chromedriver/mac64/127.0.6533.72/chromedriver-mac-arm64/THIRD_PARTY_NOTICES.chromedriver'

7r5 commented 4 months ago

some notes:

semin204 commented 4 months ago

I had the same issue. It seems that the file path in drivers.json is incorrectly specified. Manually changing the file path from THIRD_PARTY_NOTICES.chromedriver to chromedriver.exe resolved the issue, and it is now running correctly.

UPBKRATOS commented 4 months ago

I might found the issue, it seems the Latest Chrome updates (https://chromereleases.googleblog.com/) introduced a THIRD_PARTY_NOTICES file within the packed archive, having that in mind the core/driver_chage._get_binary method is just ignoring the LICENSE file hence it ended up choosing the next in the queue, that is why we see the THIRD_PARTY_NOTICES.chromedriver but that is not the executable, I don't have write access to the repo, but can someone who does, to please create a quick MR to include a logic to also ignore the third party File or pick directly the one under /chromedriver?, would be better fix it at the code level instead changing the filename manually

if any(uf in f for uf in ['LICENSE', 'THIRD_PARTY_NOTICES']):
                continue

core_driver_cache (1)

JERisBRISK commented 4 months ago
if any(uf in f for uf in ['LICENSE', 'THIRD_PARTY_NOTICES']):
                continue

This worked for me, but I feel like it might lead to us playing 'whack a mole' if the driver folks keep adding to the archive...

Hasnain-20 commented 4 months ago
driver_path = ChromeDriverManager().install()
if driver_path:
    driver_name = driver_path.split('/')[-1]
    if driver_name!="chromedriver":
        driver_path = "/".join(driver_path.split('/')[:-1]+["chromedriver"])
        os.chmod(driver_path, 0o755)
driver = webdriver.Chrome(service=Service(driver_path))

Try this fix, if you don't want to make changes in Package files.

netexpoarthur commented 4 months ago

Capture d'écran 2024-07-24 100912 That’s exactly right, @semin204 . There’s an error in the module that specifies some form of documentation as the return value of ChromeDriverManager().install(), whereas it should return the absolute path of chromedriver. It looks like an intern might have accidentally pressed the wrong button :)) !

MaysonLedur commented 4 months ago

I'm running the 4.0.2 version and still getting the error:

OSError: [WinError 193] %1 is not a valid Win32 application.

Should it be fixed in that version already? My code:

chrome_service = ChromeService(ChromeDriverManager().install())
chrome_options = Options()
driver = webdriver.Chrome(service=chrome_service, options=chrome_options)

The error began on the 127 chrome update.

netexpoarthur commented 4 months ago

@MaysonLedur Updating the version as you've done doesn't necessarily fix the problem. In fact, the problem seems to stem from the JSON file in the Chromedriver directory. Deleting the 'drivers' folder corrected the problem for me, which should solve your problem.

C:\Users\me\.wdm\drivers\chromedriver\win64\127.0.6533.72\chromedriver-win32/chromedriver.exe

MaysonLedur commented 4 months ago

netexpoarthur, thank you! That solved my problem. Have a nice one!

xiaowangAndyismengxin commented 4 months ago

you can try to update. try this https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.73/win64/chromedriver-win64.zip. find it in https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json, Find the version that is closest to the latest version. then change the version number by youself. open it. and now you can download the latest version.

Nimish05Z commented 4 months ago
driver_path = ChromeDriverManager().install()
if driver_path:
    driver_name = driver_path.split('/')[-1]
    if driver_name!="chromedriver":
        driver_path = "/".join(driver_path.split('/')[:-1]+["chromedriver"])
        os.chmod(driver_path, 0o755)
driver = webdriver.Chrome(service=Service(driver_path))

Try this fix, if you don't want to make changes in Package files.

If this also not works then just add .exe to chromedriver in driver_path. then that will be chromedriver.exe

chipolinkin commented 3 months ago

You should edit this json only --> drivers.json It works) fix2 fix3 fix4

ManuelSalaz commented 3 months ago
driver_path = ChromeDriverManager().install()
if driver_path:
    driver_name = driver_path.split('/')[-1]
    if driver_name!="chromedriver":
        driver_path = "/".join(driver_path.split('/')[:-1]+["chromedriver"])
        os.chmod(driver_path, 0o755)
driver = webdriver.Chrome(service=Service(driver_path))

Try this fix, if you don't want to make changes in Package files.

I got this error:

FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\Administrator\\.wdm\\drivers\\chromedriver\\win64\\127.0.6533.72\\chromedriver-win32/chromedriver'

ManuelSalaz commented 3 months ago
driver_path = ChromeDriverManager().install()
if driver_path:
    driver_name = driver_path.split('/')[-1]
    if driver_name!="chromedriver":
        driver_path = "/".join(driver_path.split('/')[:-1]+["chromedriver"])
        os.chmod(driver_path, 0o755)
driver = webdriver.Chrome(service=Service(driver_path))

Try this fix, if you don't want to make changes in Package files.

I got this error:

FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\Administrator\\.wdm\\drivers\\chromedriver\\win64\\127.0.6533.72\\chromedriver-win32/chromedriver'

Making a little change works! this is the code:

driver_path = ChromeDriverManager().install()
if driver_path:
    driver_name = driver_path.split('/')[-1]
    if driver_name!="chromedriver":
        driver_path = "/".join(driver_path.split('/')[:-1]+["chromedriver.exe"])
        os.chmod(driver_path, 0o755)

Service = ChromeService(driver_path)
driver = webdriver.Chrome(service=Service)
jnhyperion commented 3 months ago

I think 4.0.2 already fixed this error:

  1. update webdriver_manager to 4.0.2
  2. delete /user/user_name/.wdm/driver.json

then try again

alpcanm commented 2 months ago

I replaced

"/Users/{user}/.wdm/drivers/chromedriver/mac64/128.0.6613.137/chromedriver-mac-arm64/THIRD_PARTY_NOTICES.chromedriver"

to

"/Users/{user}/.wdm/drivers/chromedriver/mac64/128.0.6613.137/chromedriver-mac-arm64/chromedriver"

just Delete "THIRD_PARTY_NOTICES."

then fixed for me.

-Mac M1