目前在我的nightwatch.json
我设置好在Mac上运行:
{
"src_folders" : ["specs"],
"output_folder" : "tests/e2e/reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : true,
"server_path" : "bin/selenium-server-standalone-2.48.2.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "bin/chromedriver 2",
"webdriver.ie.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "someurl",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
然而,chrome的驱动程序需要运行chromedriver.exe
。解决这个问题的最佳做法是什么?我需要2个配置文件吗?我不想这样做,因为我需要对此进行额外的检查。
答案 0 :(得分:4)
解决方案是使用nightwatch.conf.js文件,即:
module.exports = (function (settings) {
//Setting chromedriver path at runtime to run on different architectures
if (process.platform === "darwin") {
settings.selenium.cli_args["webdriver.chrome.driver"] = "bin/chromedriver 2";
}
else if (process.platform === "win32" || process.platform === "win64") {
settings.selenium.cli_args["webdriver.chrome.driver"] = "bin/chromedriver.exe";
}
return settings;
})(require('./nightwatch.json'));