webdriverio-community/node-geckodriver

selenium-webdriver doesn't work with NPM-installed geckodriver.exe

mykmelez opened this issue · 5 comments

#29 didn't work quite as well as I thought at first. It does make geckodriver.exe available on the PATH, and I thought that enabled selenium-webdriver to successfully find and run it in my tests last week.

But I tested again this morning, and selenium-webdriver now silently fails after I install geckodriver via this NPM package. So perhaps I made a mistake last week when running tests on my modified version of this package.

In MozillaBuild, running geckodriver.exe complains:

$ geckodriver.exe
bash: /c/Users/myk/AppData/Roaming/npm/geckodriver.exe: /bin/sh: bad interpreter: Bad file number

In a standard cmd.exe terminal, running geckodriver.exe complains:

C:\Users\myk\project-dir>geckodriver.exe
This version of C:\Users\myk\AppData\Roaming\npm\geckodriver.exe is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.

It also displays an Unsupported 16-Bit Application dialog window with the message:

The program or feature "??\C:\Users\myk\AppData\Roaming\npm\geckodriver.exe" cannot start or run due to incompatibility with 64-bit versions of Windows. Please contact the software vendor to ask if a 64-bit Windows compatible version is available."

I suspect this is due to the .exe file extension overriding the shebang line in the Node script that NPM installs as geckodriver.exe, and we'll need a different solution for the problem, perhaps copying the actual geckodriver.exe file to a location in the PATH in the postinstall.js script.

Update: over in #31, I tried copying geckodriver.exe in the postinstall script. Over in https://github.com/mykmelez/node-geckodriver/tree/link-geckodriver-exe I made that implementation link the file instead of copying it.

Alas, neither solution is sufficient, for reasons described in #31, so in #32 I've reverted #29 and added a section to the README that describes how to manually link geckodriver.exe on Windows.

Here's the workaround for readers of this issue (so you don't have to go find the README): manually link geckodriver.exe on Windows (after installing this package globally) via this mklink command in a cmd.exe terminal:

mklink %USERPROFILE%\AppData\Roaming\npm\geckodriver.exe %USERPROFILE%\AppData\Roaming\npm\node_modules\geckodriver\geckodriver.exe

FWIW, I could not get geckodriver running on Windows10 for WebDriverJS using npm. The geckodriver.exe was always not found. I did also add the mlink, but no success.

In the end I gave up and installed geckodriver manually and added it to the system PATH. So this does not look like it is working out of the box.

Forget my last comment. I got it working in a node project on Windows 10 as dependency with npm install geckodriver --save and then in the relevant js file also doing a require('geckodriver');

Thanks all, let me know if anyone still experiences this issue and I am happy to re-open.