gpt4 book ai didi

selenium - 尝试启动 ChromeDriver : cannot resolve path: "/node_modules/.bin/chromedriver" 时发生错误

转载 作者:行者123 更新时间:2023-12-04 12:39:29 29 4
gpt4 key购买 nike

当我设置初始设置 Nightwatchjs(使用初学者教程)时,出现如下错误:

尝试启动 ChromeDriver 时出错:无法解析路径:“/node_modules/.bin/chromedriver”。

包.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"
}
}
}
}

第一个测试.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");
}
}

最佳答案

最后,当我展示他的教程的 git 帐户时,我也得到了一个解决方案也发布了解决方案。

https://github.com/coding-with-dom/intro-to-nightwatchjs/commit/a2e0e05351c9e1c9e108bdf1083ae2a03e0296d1

enter image description here

我只需要更改我的文件 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"
}
}
}
}

关于selenium - 尝试启动 ChromeDriver : cannot resolve path: "/node_modules/.bin/chromedriver" 时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60882226/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com