Nightwtch.js v1.0.18防止在未找到的组件上引发错误,.validate防止测试失败

时间:2019-01-15 12:09:30

标签: nightwatch.js

迁移到Nightwatch 1.0.18 .locateSingleElement()协议操作:.api.element()上没有此类元素错误。在守夜人0.9.20中,如果现在未找到element,则element()返回-1,它将引发错误。当找不到元素时,有没有一种方法可以停止那些错误。同样,.verify用来报告测试用例失败,现在它关闭了整个测试。

我希望能够检查组件是否存在 .element()而不会引发错误。并且 .verify()失败的案例应继续执行。

配置文件中是否缺少某些内容。我找不到任何可以阻止此行为的设置

nightwatch.json文件

{
  "src_folders" : ["Tests/tests"],
  "output_folder" : "reports",
  "custom_commands_path" : "Tests/commands",
  "custom_assertions_path" : "Tests/assertions",
  "page_objects_path" : "Tests/pages",
  "globals_path" : "Tests/globals/globals.js",

  "selenium" : {
    "start_process" : true,
    "server_path" : "./lib/selenium-server-standalone-3.9.1.jar",
    "log_path" : "",
    "port" : 4444,
    "cli_args": {
      "webdriver.chrome.driver": "./lib/chromedriver.exe",
      "webdriver.gecko.driver": "./lib/geckodriver-v0.21.0-win64.exe"
    }
  },

  "test_settings" : {
    "default": {
      "launch_url" : "https://test.dash.com/edit/",
      "webdriver": {
        "port": 4444,
        "host": "localhost",
        "silent": true
      },
      "end_session_on_fail": false,
      "screenshots": {
      "enabled": true,
      "on_failure": true,
      "path": "screenshots"
      },
      "desiredCapabilities": {
        "browserName": "chrome",
        "loggingPrefs": { "browser": "ALL" },
        "javascriptEnabled": true,
        "acceptSslCerts": true
      },
      "globals": {
        "browser": "chrome",
        "os": "windows",
        "abortOnAssertionFailure": false
      }
    }
  }
}

测试输出: Debugged in VS code see error with selector in console

0 个答案:

没有答案