Nightwatch - 使用 chromedriver
Nightwatch - Use chromedriver
所以我在堆栈上看到了一个类似的问题 here 但它没有被接受的答案,也没有为我提供我需要的信息..
我正在尝试使用 'chromedriver',因为 'selenium-webdriver' 需要 FF 版本 <= 28。
到目前为止我做了什么。
- nightwatch.js 在 FF
中测试 运行ning 正常
- 已将 chrome 驱动程序(
npm install chromedriver -g
)和 npm install chromedriver
下载到我的守夜人项目目录中
转到nightwatch/bin/nightwatch.json
并编辑了以下代码
"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/usr/local/bin/chromedriver", <= added this - is this the binary?
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}},
还尝试将 selenium 的设置更新为 start_process=true 和 server_path
"selenium" : {
"start_process" : true,
"server_path" : "../selenium-server-standalone-2.39.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/usr/local/bin/chromedriver",
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}
},
不确定我是否指向正确的chrome驱动程序file/folder
还编辑了测试设置
"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" : ""
},
"desiredCapabilities" : {
"browserName" : "chrome", <= changed this from ff to chrome
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
如果我参加 运行 测试(没有 -e <browser>
),例如nightwatch -g <group>
,它在 FF 和 运行s..
中正常启动
如果我尝试指定 chrome 浏览器 (-e chrome
) nightwatch -g <group> -e chrome
我会收到以下错误
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:354:15)
at Object.CliRunner.init (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:31:8)
at module.exports.runner.runner (/usr/local/lib/node_modules/nightwatch/lib/index.js:512:19)
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:7)
at Object.<anonymous> (/usr/local/lib/node_modules/nightwatch/bin/runner.js:8:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
我的问题是:
如何指向二进制文件(不确定是哪个)
我在 nightwatch.js 中的设置是否正确?如果我更改了 test_settings 'browserName = Chrome"?
,在 FF 中如何 运行ning
我是不是遗漏了什么?
提前致谢
确保在项目的根目录中创建一个新的nightwatch.json文件。
我犯的错误是试图使用 http://nightwatchjs.org/ 下载的包附带的 nightwatch.json 文件,该文件位于 nightwatch-0.6.11/bin/nightwatch.json
你先说
I am trying to use 'chromedriver' because 'selenium-webdriver'
requires a FF version <= 28.
这是因为您使用的是 selenium-server-standalone-2.39。0.jar(旧 jar)请从这里下载新的 selenium-server-standalone-2.45.0.jar
第二次从这里下载 chrome 驱动程序 Chromedriver 根据您的环境
第三次更新您的 nightwatch.json 使用以下代码
{
"src_folders": [
"tests"
],
"selenium": {
"start_process": false,
"server_path": "bin/selenium-server-standalone-2.45.0.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "bin/chromedriver",
"webdriver.ie.driver": ""
}
},
"test_settings": {
"default": {
"launch_url": "http://127.0.0.1/",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
第四个运行你的组with nightwatch -g -e chrome
希望能解决您的问题。
"selenium": {
"start_process":true,
"server_path": "bin/selenium.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "",
"webdriver.ie.driver": ""
}
},
以上代码帮助我 运行 selenium 服务器 by nightwatch
所以我在堆栈上看到了一个类似的问题 here 但它没有被接受的答案,也没有为我提供我需要的信息..
我正在尝试使用 'chromedriver',因为 'selenium-webdriver' 需要 FF 版本 <= 28。
到目前为止我做了什么。
- nightwatch.js 在 FF 中测试 运行ning 正常
- 已将 chrome 驱动程序(
npm install chromedriver -g
)和npm install chromedriver
下载到我的守夜人项目目录中 转到
nightwatch/bin/nightwatch.json
并编辑了以下代码"selenium" : { "start_process" : false, "server_path" : "", "log_path" : "", "host" : "127.0.0.1", "port" : 4444, "cli_args" : { "webdriver.chrome.driver" : "/usr/local/bin/chromedriver", <= added this - is this the binary? "webdriver.ie.driver" : "", "webdriver.firefox.profile" : "" }},
还尝试将 selenium 的设置更新为 start_process=true 和 server_path
"selenium" : {
"start_process" : true,
"server_path" : "../selenium-server-standalone-2.39.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/usr/local/bin/chromedriver",
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}
},
不确定我是否指向正确的chrome驱动程序file/folder
还编辑了测试设置
"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" : ""
},
"desiredCapabilities" : {
"browserName" : "chrome", <= changed this from ff to chrome
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
如果我参加 运行 测试(没有 -e <browser>
),例如nightwatch -g <group>
,它在 FF 和 运行s..
如果我尝试指定 chrome 浏览器 (-e chrome
) nightwatch -g <group> -e chrome
我会收到以下错误
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:354:15)
at Object.CliRunner.init (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:31:8)
at module.exports.runner.runner (/usr/local/lib/node_modules/nightwatch/lib/index.js:512:19)
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:7)
at Object.<anonymous> (/usr/local/lib/node_modules/nightwatch/bin/runner.js:8:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
我的问题是:
如何指向二进制文件(不确定是哪个)
我在 nightwatch.js 中的设置是否正确?如果我更改了 test_settings 'browserName = Chrome"?
,在 FF 中如何 运行ning
我是不是遗漏了什么?
提前致谢
确保在项目的根目录中创建一个新的nightwatch.json文件。
我犯的错误是试图使用 http://nightwatchjs.org/ 下载的包附带的 nightwatch.json 文件,该文件位于 nightwatch-0.6.11/bin/nightwatch.json
你先说
I am trying to use 'chromedriver' because 'selenium-webdriver' requires a FF version <= 28.
这是因为您使用的是 selenium-server-standalone-2.39。0.jar(旧 jar)请从这里下载新的 selenium-server-standalone-2.45.0.jar 第二次从这里下载 chrome 驱动程序 Chromedriver 根据您的环境
第三次更新您的 nightwatch.json 使用以下代码
{
"src_folders": [
"tests"
],
"selenium": {
"start_process": false,
"server_path": "bin/selenium-server-standalone-2.45.0.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "bin/chromedriver",
"webdriver.ie.driver": ""
}
},
"test_settings": {
"default": {
"launch_url": "http://127.0.0.1/",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
第四个运行你的组with nightwatch -g -e chrome
希望能解决您的问题。
"selenium": {
"start_process":true,
"server_path": "bin/selenium.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "",
"webdriver.ie.driver": ""
}
},
以上代码帮助我 运行 selenium 服务器 by nightwatch