我想使用我编写的 UI 测试来实现 CI/CD,以便每晚自动运行 Nightwatch.js 测试。我尝试将文件复制到 Jenkins 的工作区并运行它们。我尝试过使用 TFS 作为版本控制系统,看看是否可以让它以这种方式运行。我一直遇到的问题(见附件)是,当我在本地运行时,chrome 浏览器会打开并运行测试。然而,在 Jenkins 中,它说找不到该元素。我研究了如何 headless 运行 chrome,但是当我将 --headless 标签添加到 nightwatch.json 配置文件时,我仍然遇到相同的错误。底线是,如何让 Nightwatch.js 测试按每晚计划运行? (最好在 Jenkins )
尝试从 tfs 源代码管理运行测试 尝试从复制到 Jenkins 工作区的本地测试运行测试。 尝试运行 headless 测试(本地有效,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"
}
}
}
}
最佳答案
看起来 .windowMaximize() 导致我的测试在 Jenkins 中挂起并失败。
关于node.js - 如何在 Jenkins 中运行 Nightwatch.js 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55618125/