如何在Jenkins中运行Nightwatch.js测试?

问题描述 投票:2回答:1

我想用我编写的UI测试来实现CI / CD,以便每晚自动运行我的Nightwatch.js测试。我已经尝试将我的文件复制到jenkins的工作区并运行它们。我已经尝试使用TFS作为版本控制系统,看看我们是否可以让它以这种方式运行。我一直遇到的问题(见附件)是当我在本地运行时,Chrome浏览器打开并运行测试就好了。然而,在詹金斯,它说它找不到元素。我已经研究过如何无头地运行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"
        }
      }
    }
  }

我希望我的测试通常在jenkins中运行,如果ui.Error received from Jenkins通过或失败,我会给我一份详细的报告

node.js jenkins tfs nightwatch.js
1个回答
0
投票

看起来.windowMaximize()导致我的测试在Jenkins中挂起并失败。

© www.soinside.com 2019 - 2024. All rights reserved.