nightwatch: Starting ChromeDriver: cannot resolve path to chromedriver in Windows environment
Overview
Hi all, So I was following the instructions from nightwatchjs.org/gettingstarted, and setup nightwatch in one of my projects. It seems that running nightwatch in a Windows environment produces the following error:
An error occurred while trying to start ChromeDriver: cannot resolve path: "./node_modules/.bin/chromedriver".
Please check that the "webdriver.server_path" config property is set correctly.
This might not only be a chromedriver issue, see the Environment section below. If it is, I can open this issue over there.
I am also not the only one who has seen this issue: #1960
Test Repo
I have made a bare minimum repo with instructions that produces the error here: https://github.com/chriswoodle/nightwatch-windows-chromedriver-bug
Environment
Chromedriver: 2.45.0 Node: 8.12.0 NPM: 6.4.1 OS: Windows 10 1809
I can confirm that this is not an issue in at least MacOS.
I can also confirm that this error happens on other Windows machines, not the only environment described above.
It might not be a chromedriver issue, since chromedriver can be invoked from npm scripts without error.
package.json
{
...
"scripts": {
"chromedriver": "chromedriver -v"
}
}
=>
ChromeDriver 2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387)
Full error
npm run nightwatch
> universal-ws-tools@ nightwatch C:\Users\Super\git\universal-ws
> nightwatch ./test/browser/nightwatch.js --verbose
Starting ChromeDriver on port 9515...
An error occurred while trying to start ChromeDriver: cannot resolve path: "./node_modules/.bin/chromedriver".
Please check that the "webdriver.server_path" config property is set correctly.
ChromeDriver process closed.
Wrote log file to: C:\Users\Super\git\universal-ws\chromedriver.log.
Thanks for your help!
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (1 by maintainers)
Commits related to this issue
- fix issue #1992 - chromedriver path on windows — committed to KGBemployee/nightwatch by KGBemployee 5 years ago
I have the same issue on Windows with http://nightwatchjs.org/gettingstarted. And finaly got this to work with this
nightwatch.conf.js:Just got chromedriver
pathproperty and setwebdriver.server_pathwith that property.After experiencing this problem, myself, I came across this Issue. Many thanks to @dvalejo and @chriswoodle, as I found both:
Solution 1: nightwatch.conf.js
By overriding the test environments, you don’t have to a) detect the current environment or b) have multiple conf.js files. See that commented out
.log(). Leads to…Solution 2: using nightwatch.json only
Inspecting the
.pathshowed that nightwatch is looking specifically for the.exefile. It does not accept the.cmdor non-extension file. Pointing your test environments directly to the.exesolved most issues almost immediately. Here is mynightwatch.jsonfile.Either solution works equally well, but the
nightwatch.conf.jsis probably more future proof and less hassle. If geckodriver or chromedriver change their structure, you don’t have to manually inspect for the.exewhich is not innode_modules/.bin/, where it is supposed to be.Hopefully, this gives some insight and helps some others.
P.S: I also want to note that I was having the same problem with Firefox, as well. This is what necessitated the generic function
Hello All!
I was able to solve this issue just now by doing the following:
This now exits properly on completion on Windows.
This solved my problem “server_path”: “node_modules/chromedriver/lib/chromedriver/chromedriver.exe” insted of ‘server_path’: ‘node_modules/.bin/chromedriver’,
I resolved this by downloading the chromedriver files manually from here and adjusting the path inside nightwatch.json instead of
node_modules/.bin/chromedrivertonode_modules/.bin/chromedriver.exe. I use Windows machine and I believe the problem is thatnpm installcommand missed to install .exe file for me.