使用 Nightwatch 的 Chromedriver 错误 "Chrome version must be >= 52"

Chromedriver error "Chrome version must be >= 52" using Nightwatch

我正在尝试设置 Nightwatch, and am using the latest chromedriver which says it supports chrome v52-54。但是,当我尝试 运行 测试时,它说 'Error: Chrome version must be >=52.0.2743.' 这是我正在使用的所有内容:

项目结构

|-- nightwatch.json
|-- bin/
|   |-- chromedriver
|   |-- selenium-server-standalone-2.53.1.jar
|-- tests/
|   |-- sample.js
|-- results/
|-- screens/
|-- node_modules/
|   |-- (lots of modules here)

这是我的 configuration file 守夜人:

./nightwatch.json

{
  "src_folders" : ["tests"],
  "output_folder" : "results",
  "custom_commands_path" : "",
  "custom_assertions_path" : "",
  "page_objects_path" : "",
  "globals_path" : "",

  "selenium" : {
    "start_process" : true,
    "server_path" : "bin/selenium-server-standalone-2.53.1.jar",
    "log_path" : "results",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "bin/chromedriver"
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost",
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "silent": true,
      "screenshots" : {
        "enabled" : true,
        "path" : "screens/"
      },
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },

    "chrome" : {
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    }
  }
} 

运行 测试

我运行这样的测试:

nightwatch tests/

错误

我得到以下输出:

Starting selenium server... started - PID:  3500

[Sample] Test Suite
=======================

Running:  Demo test Google

Error retrieving a new session from the selenium server

Connection refused! Is selenium server started?
{ sessionId: null,
  status: 13,
  state: 'unhandled error',
  value: 
   { message: 'unknown error: Chrome version must be >= 52.0.2743.0\n  (Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 3.2.0-56-generic x86_64) (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 1.42 seconds\nBuild info: version: \'2.53.1\', revision: \'a36b8b1\', time: \'2016-06-30 17:37:03\'\nSystem info: host: \'N/A\', ip: \'N/A\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.2.0-56-generic\', java.version: \'1.7.0_111\'\nDriver info: org.openqa.selenium.chrome.ChromeDriver',
     suppressed: [],
     localizedMessage: 'unknown error: Chrome version must be >= 52.0.2743.0\n  (Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 3.2.0-56-generic x86_64) (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 1.42 seconds\nBuild info: version: \'2.53.1\', revision: \'a36b8b1\', time: \'2016-06-30 17:37:03\'\nSystem info: host: \'N/A\', ip: \'N/A\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.2.0-56-generic\', java.version: \'1.7.0_111\'\nDriver info: org.openqa.selenium.chrome.ChromeDriver',
     buildInformation: 
      { releaseLabel: '2.53.1',
        buildTime: '2016-06-30 17:37:03',
        class: 'org.openqa.selenium.internal.BuildInfo',
        buildRevision: 'a36b8b1',
        hCode: 1900167016 },
     cause: null,
     systemInformation: 'System info: host: \'N/A\', ip: \'N/A\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.2.0-56-generic\', java.version: \'1.7.0_111\'',
     supportUrl: null,
     class: 'org.openqa.selenium.WebDriverException',
     additionalInformation: '\nDriver info: org.openqa.selenium.chrome.ChromeDriver',
     hCode: 1299270263,
     screen: null },
  class: 'org.openqa.selenium.remote.Response',
  hCode: 1144687147 }

有人知道如何解决这个错误吗?

Chrome version must be >= 52.0.2743.0

chrome驱动程序是否使用我的 chrome 本地副本?我需要更新我的实际 chrome 吗?

Does chromedriver use my local copy of chrome? Do I need to update my actual chrome?

是的,ChromeDriver是selenium webdriver用来控制chrome的可执行文件。

因此 selenium webdriver 从您在初始化期间告诉 selenium webdriver 的默认位置或自定义位置启动您安装的 chrome ChromeDriver

所以基本上 ChromeDriver 可执行文件只是用来在 chrome 浏览器和 selenium webdriver 之间进行对话来控制它,这并不意味着它会启动自己的 chrome 浏览器。它使用您安装的 chrome 浏览器。

是的,您需要更新实际安装的 chrome。

是的,Chrome驱动程序使用本地 Chrome 安装。如果您不想升级 Chrome 安装,您可以指定一个 Chrome 驱动程序版本,该版本可以与安装的 Chrome 版本一起使用。

您可以在 https://chromedriver.storage.googleapis.com/2.25/notes.txt 找到不同 Chrome 驱动程序版本的兼容 Chrome 版本(如果您的 Chrome 版本较新,请将“2.25”更改为较新的版本比那里列出的更多)。

如果您的测试框架使用 Node.js webdriver-manager,您可以简单地安装所需的 Chrome 驱动程序版本(保留任何已安装的版本)使用(例如版本 2.20):

webdriver-manager update --chrome --versions.chrome=2.20

并在通过 webdriver-manager:

启动 Selenium 时指定适当的 Chrome 驱动程序版本
webdriver-manager start --versions.chrome=2.20

如果webdriver-manager不可用,您可以简单地下载所需的Chrome驱动程序版本并使用一些技术将以下参数传递给Selenium服务器启动命令:

-Dwebdriver.chrome.driver=/path/to/the/desired/chromedriver_version

如果您使用的是 Ubuntu 16.04,此代码有效:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

x64

sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'

x32

sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'

Install/Update

sudo apt-get update
sudo apt-get install google-chrome-stable

Source