我不能运行nightwatch来运行chrome上的测试。
这是我从nightwatch示例下载的修改后的nightwatch.json:
{
"src_folders" : ["./examples/tests"],
"output_folder" : "./examples/reports",
"custom_commands_path" : "./examples/custom-commands",
"custom_assertions_path" : "",
"globals_path" : "./examples/globals.json",
"live_output" : false,
"selenium" : {
"start_process" : false,
"server_path" : "/lib/sel-serv.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/lib/chromedriver/chromedriver.exe",
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"chrome":{
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
}
},
"desiredCapabilities": {
"name" : "test-example",
"browserName": "chrome"
},
"globals" : {
"myGlobal" : "some_sauce_global"
},
"selenium" : {
"start_process" : false
}
}
}我得到了这个错误信息:
ERROR There was an error while starting the test runner:
Error: Invalid testing environment specified: chrome
at Object.CliRunner.parseTestSettings (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:448:15)
at Object.CliRunner.init (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:49:8)
at module.exports.runner.runner (/usr/local/lib/node_modules/nightwatch/lib/index.js:546:17)
at /usr/local/lib/node_modules/nightwatch/bin/runner.js:9:16
at module.exports.cli.cli (/usr/local/lib/node_modules/nightwatch/lib/index.js:504:5)
at Object.<anonymous> (/usr/local/lib/node_modules/nightwatch/bin/runner.js:8:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)我还发现了一个旧的帖子,说你必须在根目录中创建新文件,所以试一试,什么也没有发生
发布于 2016-04-28 19:37:57
我认为你需要在lib前加一个点:
"webdriver.chrome.driver" : "./lib/chromedriver/chromedriver.exe",还有selenium.jar:
"server_path" : "./lib/sel-serv.jar",发布于 2017-05-16 15:17:37
Selenium服务器jar路径和chrome驱动程序(.exe)路径设置不正确。使用点(“.”)在设置路径之前表示您的工作目录。或者删除chrome驱动程序和selenium服务器jar文件路径前的正斜杠(“/”)。
您必须手动运行Selenium服务器独立jar文件,因为您没有将"start_process“设置为"true”。在此处检查Selenium配置:http://nightwatchjs.org/gettingstarted/
您已经两次将start_process属性设置为false。从json文件中删除最后一个元素。("selenium“:{ "start_process”:false })
在开始执行之前,还要检查浏览器版本和驱动程序是否兼容。(检查下载驱动程序的自述文件。在readMe文件的第一行将有浏览器兼容版本)。
发布于 2017-11-29 19:00:05
只需检查配置文件并将chrome对象放入默认对象之外,例如,
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
}
},
"chrome":{
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
like this....have a blasthttps://stackoverflow.com/questions/36883009
复制相似问题