【发布时间】:2019-09-01 05:47:25
【问题描述】:
我想使用我编写的 UI 测试来实现 CI/CD,以便每晚自动运行我的 Nightwatch.js 测试。我尝试将我的文件复制到詹金斯的工作区并运行它们。我尝试使用 TFS 作为版本控制系统,看看我们是否可以让它以这种方式运行。我一直遇到的问题(见附件)是,当我在本地运行时,chrome 浏览器会打开并正常运行测试。然而,在 Jenkins 中,它说它找不到元素。我研究了如何无头运行 chrome,但是当我将 --headless 标记添加到我的 nightwatch.json 配置文件时,我仍然遇到同样的错误。底线,我怎样才能让 Nightwatch.js 测试按每晚的时间表运行? (最好在詹金斯)
尝试从 tfs 源代码控制运行测试 尝试从复制到詹金斯工作区的本地测试运行测试。 尝试运行无头测试(本地有效,Jenkins 无效)https://developers.google.com/web/updates/2017/04/headless-chrome
这是我的 nightwatch.json 文件。
{
"src_folders" : ["tests"],
"output_folder" : "reports/XMLReports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "dealer",
"globals_path" : "",
"test_workers": false,
"selenium": {
"cli_args": {
"webdriver.chrome.driver" : "node_modules/.bin/chromedriver.cmd",
"webdriver.gecko.driver" : "node_modules/.bin/geckodriver.cmd",
"webdriver.edge.driver" : "node_modules/.bin/edgedriver.cmd"
},
"log_path": "",
"port": 4460,
"server_path": "lib/drivers/selenium-server-standalone-3.141.59.jar",
"start_process": true
},
"test_settings" : {
"chrome" : {
"launch_url" : "http://localhost",
"selenium_port" : 4460,
"selenium_host" : "127.0.0.1",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : "screenshots/Chrome/"
},
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions":{
"args": [
"disable-web-security",
"ignore-certificate-errors",
"--test-type",
"--disable-gpu",
"--headless",
"--remote-debugging-port=9222"
]
}
}
},
"edge" : {
"desiredCapabilities": {
"browserName": "MicrosoftEdge"
}
}
}
}
【问题讨论】:
标签: node.js jenkins tfs nightwatch.js