gpt4 book ai didi

nightwatch.js - 如何将 nightwatch.json 设置为跨平台

转载 作者:行者123 更新时间:2023-12-04 07:30:46 25 4
gpt4 key购买 nike

目前在我的 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个配置文件吗?我宁愿不要这个,因为我需要对此进行额外检查。

最佳答案

解决方案是使用 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'));

关于nightwatch.js - 如何将 nightwatch.json 设置为跨平台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34066864/

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