守夜人:检索新会话时发生错误

Mar*_*inh 6 javascript selenium selenium-chromedriver selenium-webdriver nightwatch.js

在我的反应项目中,我想使用夜视仪作为测试工具.我实际上在Windows上使用Nightwatch v1.0.4和selenium-server-standalone-3.9.1.jar.

这是我的配置(nightwatch.json):

{
  "src_folders": [
    "tests"
  ],
  "output_folder": "reports",
  "custom_commands_path": "",
  "custom_assertions_path": "",
  "page_objects_path": "",
  "globals_path": "",
  "disable_colors": false,
  "test_workers": false,
  "selenium": {
    "start_process": true,
    "host": "localhost",
    "port": 4444,
    "server_path": "./bin/selenium-server-standalone-3.9.1.jar",
    "log_path": "./logs",
    "cli_args": {
      "webdriver.chrome.driver": "./bin/chromedriver"
    }
  },
  "desiredCapabilities": {
    "browserName": "chrome",
    "acceptSslCerts": true
  },
  "test_settings": {
    "default": {
      "webdriver": {
        "server_path": "./bin/chromedriver",
        "cli_args": [
          "--log",
          "debug"
        ]
      },
      "disable_colors": false,
      "screenshots": {
        "enabled": false,
        "path": ""
      },
      "request_timeout_options": {
        "timeout": 60000,
        "retry_attempts": 5
      },
      "default_path_prefix" : "",
      "desiredCapabilities": {
        "browserName": "chrome",
        "acceptInsecureCerts": true
      }
    },
    "chrome": {
      "webdriver": {
        "port": 9515,
        "default_path_prefix": "",
        "server_path": "./bin/chromedriver",
        "cli_args": [
          "--verbose"
        ]
      },
      "desiredCapabilities": {
        "browserName": "chrome",
        "loggingPrefs": {
          "driver": "INFO",
          "server": "OFF",
          "browser": "INFO"
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我的测试文件(tests/index.js):

const host = 'http://localhost:3000'

module.exports = {
    'Demo test' : function (browser) {
        browser
            .url('http://google.com')
            .waitForElementVisible('body', 1000)
            .pause(5000)
            .end();
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行时nightwatch,它给我以下错误:

在此输入图像描述

谁能告诉我,我做错了什么?

dem*_*123 0

您提到的 ChromeDriver 版本相当v2.9旧。

从 ChromeDriver 下载页面开始,根据您的 Chrome 版本,您应该使用上面的 ChromeDriver 版本2.36- 我会推荐最新的2.38