Reputation: 1041
When I am setting the initial setup Nightwatchjs(using the beginner tutorial) I got the error like:
An error occurred while trying to start ChromeDriver: cannot resolve path: "/node_modules/.bin/chromedriver".
package.json
{
"name": "intro-to-nightwatchjs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "nightwatch"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"chromedriver": "^80.0.1",
"minimist": "^1.2.5",
"nightwatch": "^1.3.4",
"optimist": "^0.6.1"
}
}
nightwatch.conf.js
module.exports = {
"src_folders" : ["tests"],
"webdriver" : {
"start_process": true,
"server_path": "/node_modules/.bin/chromedriver",
"port": 9515
},
"test_settings" : {
"default" : {
"desiredCapabilities": {
"browserName": "chrome"
}
}
}
}
firstTest.js
module.exports = {
'My first test case'(browser){
browser
.url("https://www.bla-bla.com/")
.waitForElementVisible('.bla-bla-class')
.assert.containsText(".bla-bla-class", "bla bla text");
}
}
Upvotes: 4
Views: 2212
Reputation: 1041
Finally, I got a solution when I show his git account of the tutorial also post the solution too.
I just need to change my file nightwatch.conf.js
module.exports = {
"src_folders" : ["tests"],
"webdriver" : {
"start_process": true,
"server_path": require('chromedriver').path,
"port": 9515
},
"test_settings" : {
"default" : {
"desiredCapabilities": {
"browserName": "chrome"
}
}
}
}
Upvotes: 7