Chromedriver错误“Chrome版本必须> = 52”使用Nightwatch

时间:2016-09-17 00:33:40

标签: selenium selenium-webdriver selenium-chromedriver nightwatch.js

我正在尝试设置Nightwatch,并且正在使用最新的chromedriver ,并说明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

chromedriver是否使用我当地的chrome副本?我是否需要更新我的实际Chrome?

3 个答案:

答案 0 :(得分:15)

  

chromedriver是否使用我当地的chrome副本?我是否需要更新我的实际Chrome?

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

因此,selenium webdriver会在默认位置或自定义位置启动您安装的Chrome,并在初始化ChromeDriver时告诉selenium webdriver。

所以基本上ChromeDriver可执行文件只是用来讨论chrome浏览器和selenium webdriver来控制它,这并不意味着它启动了自己的chrome浏览器。它使用您安装的Chrome浏览器。

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

答案 1 :(得分:11)

是的,ChromeDriver使用您当地的Chrome安装。如果您不想升级Chrome安装,可以指定适用于已安装的Chrome版本的ChromeDriver版本。

您可以在https://chromedriver.storage.googleapis.com/2.25/notes.txt找到适用于不同ChromeDriver版本的兼容Chrome版本(如果您的Chrome版本比其中列出的版本更新,则将“2.25”更改为较新版本。)

如果您的测试框架使用Node.js webdriver-manager,您只需安装所需的ChromeDriver版本(保留所有已安装的版本)(例如版本2.20):

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

并在通过webdriver-manager启动Selenium时指定相应的ChromeDriver版本:

webdriver-manager start --versions.chrome=2.20

如果webdriver-manager不可用,您只需下载所需的ChromeDriver版本并使用某种技术将以下参数传递给Selenium服务器启动命令:

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

答案 2 :(得分:5)

如果您正在使用Ubuntu 16.04,则此代码有效:

[String: Any]

<强> 64

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

<强> X32

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

安装/更新

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

Source