OSX fix Selenium Chromedriver launch error spawn Unknown system error -86 Bad CPU type in executable?

北城以北 提交于 2021-01-18 12:03:33

问题


Suddenly on the afternoon of January 6, 2021, my Selenium Protractor tests under OSX stopped working with the mysterious error

spawn Unknown system error -86

I did some research and discovered that error number 86 is the same as

Bad CPU type in executable

and ran the following to compare the cpu architecture of my chromedriver binary to my system:

% file chromedriver_87.0.4280.88
chromedriver_87.0.4280.88: Mach-O 64-bit executable arm64
% uname -a
Darwin kobl179273m 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64
% uname -p
i386

How can I fix the chromedriver binary used by my Selenium so that it will run on my Intel x64 mac and clear the "system error -86" or "Bad CPU type" message?


回答1:


This has been now fixed in 12.1.8 so just update to that webdriver manager




回答2:


As per Deepak Srinivasan's comment above, this error is caused by https://github.com/angular/webdriver-manager/issues/476

Root Cause: The ChromeDriver team added "_m1" to the end of the filename for their Apple Silicon ARM builds of Chromedriver -- but both the Silicon and Intel versions of chromedriver have "mac64" in the filename, and the version number is exactly the same. This causes webdriver-manager to always download the Silicon build of Chromedriver, even on Intel macs. As a general solution, simply avoid using the chromedriver that has _m1 in its filename if you are on an Intel mac.

Solution 1: Downgrade to Chrome 86.0.4240.198 and Chromedriver 86.0.4240.22. These versions work together and are the most recent versions prior to the new and problematic support for Silicon ARM

Chrome 86 download page: https://google-chrome.en.uptodown.com/mac/download/2920124

Disable auto-updates in Chrome: https://superuser.com/questions/1359017/how-do-i-disable-automatic-updates-of-google-chrome-on-mac-os-x

Chromedriver 86: https://chromedriver.storage.googleapis.com/index.html?path=86.0.4240.22/

% webdriver-manager update --versions.chrome=86.0.4240.22

Solution 2: Modify the webdriver-manager npm package to point to the correct chromedriver (thanks to ciekaway from the angular github issue page for this fix)

Modify the following file

node_modules/webdriver-manager/built/lib/files/file_manager.js

or, if using protractor

node_modules/protractor/node_modules/webdriver-manager/built/lib/files/file_manager.js

Near the top of the downloadFile method around line 166, add the following line to remove "_m1" from the name of the file:

fileUrl.url = fileUrl.url.replace(/_m1/, '');

It needs to be after the beginning of the .then block that starts with

binary.getUrl(binary.version()).then(fileUrl => {

it also needs to be before the next reference to fileUrl.
For example:

binary.getUrl(binary.version()).then(fileUrl => {
    binary.versionCustom = fileUrl.version;
    fileUrl.url = fileUrl.url.replace(/_m1/, '');
    let filePath = path.resolve(outputDir, binary.filename());

Note that this solution is temporary. It will be overwritten by an npm install. The Chromedriver and/or the webdriver-manager team will probably fix this issue, at which point you should clear the modified version of your webdriver-manager and download the fix from npm.



来源:https://stackoverflow.com/questions/65618558/osx-fix-selenium-chromedriver-launch-error-spawn-unknown-system-error-86-bad-cp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!