Javascript Selenium 服务器错误:无法创建新服务 chromedriverservice

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48834963/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 04:15:14  来源:igfitidea点击:

Selenium server error: Unable to create new service chromedriverservice

javascriptnode.jsseleniumwebdriver-io

提问by Planet_Man

I am trying to run webdriverio on my windows 10 computer and keep running into the same issue when trying to run my test js file. So I run this -jar /your/download/directory/selenium-server-standalone-3.5.3.jarto start the server and that comes out with this output

我正在尝试在我的 Windows 10 计算机上运行 webdriverio,并在尝试运行我的测试 js 文件时一直遇到同样的问题。所以我运行它-jar /your/download/directory/selenium-server-standalone-3.5.3.jar来启动服务器,然后输出

13:06:19.471 INFO - Selenium build info: version: '3.5.3', revision: 'a88d25fe6b'
13:06:19.472 INFO - Launching a standalone Selenium Server
2018-02-16 13:06:19.503:INFO::main: Logging initialized @301ms to org.seleniumhq.jetty9.util.log.StdErrLog
13:06:19.564 INFO - Driver class not found: com.opera.core.systems.OperaDriver
13:06:19.600 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
 registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN10
13:06:19.640 INFO - Using the passthrough mode handler
2018-02-16 13:06:19.673:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2018-02-16 13:06:19.697:WARN:osjs.SecurityHandler:main: [email protected]@3e9b1010{/,null,STARTING} has uncovered http methods for path: /
2018-02-16 13:06:19.703:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@3e9b1010{/,null,AVAILABLE}
2018-02-16 13:06:19.807:INFO:osjs.AbstractConnector:main: Started ServerConnector@4e7dc304{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2018-02-16 13:06:19.808:INFO:osjs.Server:main: Started @605ms
13:06:19.808 INFO - Selenium Server is up and running

So after that I opened up a new command line prompt and ran my test.js file that looks like this

所以在那之后我打开了一个新的命令行提示符并运行了我的 test.js 文件,看起来像这样

var webdriverio = require('webdriverio');
var options = {
    desiredCapabilities: {
        browserName: 'chrome'
    }
};

webdriverio
    .remote(options)
    .init()
    .url('http://www.google.com')
    .getTitle().then(function(title) {
        console.log('Title was: ' + title);
    })
    .end()
    .catch(function(err) {
        console.log(err);
    });

And this is the error I get

这是我得到的错误

{ Error: A new session could not be created.
    at end() - C:\Users\KenyaThompson\Desktop\test.js:16:6
  details: undefined,
  message: 'Unable to create new service: ChromeDriverService\nBuild info: version: \'3.5.3\', revision: \'a88d25fe6b\', time: \'2017-08-29T12:54:15.039Z\'\nSystem info: host: \'LAPTOP-9GIHGJ9I\', ip: \'10.0.0.243\', os.name: \'Windows 10\', os.arch: \'amd64\', os.version: \'10.0\', java.version: \'1.8.0_161\'\nDriver info: driver.version: unknown',
  type: 'RuntimeError',
  seleniumStack:
   { type: 'SessionNotCreatedException',
     message: 'A new session could not be created.',
     orgStatusMessage: 'Unable to create new service: ChromeDriverService\nBuild info: version: \'3.5.3\', revision: \'a88d25fe6b\', time: \'2017-08-29T12:54:15.039Z\'\nSystem info: host: \'LAPTOP-9GIHGJ9I\', ip: \'10.0.0.243\', os.name: \'Windows 10\', os.arch: \'amd64\', os.version: \'10.0\', java.version: \'1.8.0_161\'\nDriver info: driver.version: unknown' } }

Could someone please explain to me what I am doing wrong here? Also yes I already installed chromedriver via npm as well as wdio-chromedriver-service.

有人可以向我解释我在这里做错了什么吗?另外是的,我已经通过 npm 和 wdio-chromedriver-service 安装了 chromedriver。

回答by Kyle Kohler

Update your ChromeDriver version via webdriver-manager, as follows:

通过 webdriver-manager 更新您的 ChromeDriver 版本,如下所示:

webdriver-manager clean
webdriver-manager update
webdriver-manager start

This will remove the older version, update with the latest stated in your built config, and restart the server. Hope this helps.

这将删除旧版本,使用构建配置中声明的最新版本进行更新,然后重新启动服务器。希望这可以帮助。

回答by JuliaA

When you start your Grid Node, make sure the path to the chromedriver.exe in -Dwebdriver.chrome.driverparameter is correct: Example:

启动网格节点时,请确保-Dwebdriver.chrome.driver参数中chromedriver.exe的路径正确:示例:

java -Dwebdriver.chrome.driver="C:\DEV\eclipse\MainWorkspace\webdrivers\chromedriver.exe" -jar selenium-server-standalone-3.141.59.jar -role node  -hub http://localhost:4444/grid/register -nodeConfig node-config.json > node_output.log 

回答by DebanjanB

The error you are seeing does gives us some hint about whats going wrong as follows :

您看到的错误确实为我们提供了一些有关问题的提示,如下所示:

   { type: 'SessionNotCreatedException',
     message: 'A new session could not be created.',
     orgStatusMessage: 'Unable to create new service: ChromeDriverService\nBuild info: version: \'3.5.3\', revision: \'a88d25fe6b\', time: \'2017-08-29T12:54:15.039Z\'\nSystem info: host: \'LAPTOP-9GIHGJ9I\', ip: \'10.0.0.243\', os.name: \'Windows 10\', os.arch: \'amd64\', os.version: \'10.0\', java.version: \'1.8.0_161\'\nDriver info: driver.version: unknown' }

It is clear from the error message that the ChromeDriveris not getting detected as you see the log message as Driver info: driver.version: unknown. The main reason of this error can be the incompatibility between the binaries you are using.

从错误消息中可以清楚地看出ChromeDriver没有被检测到,因为您看到的日志消息为Driver info: driver.version:unknown。此错误的主要原因可能是您使用的二进制文件之间不兼容。

  • Your Selenium Clientversion is 3.5.3released 2017-08-29T12:54:15.039Z
  • Your ChromeDriverversion is unknownto us.
  • Your Chrome Browserversion is unknownto us.
  • 你的Selenium Client版本是3.5.3发布2017-08-29T12:54:15.039Z
  • 我们不知道您的ChromeDriver版本。
  • 我们不知道您的Chrome 浏览器版本。

Solution

解决方案

A quick solution would be to :

一个快速的解决方案是:

  • Update Selenium Clientversion to recent levels i.e. Selenium 3.9.1
  • Update ChromeDriverversion to recent levels i.e. ChromeDriver 2.35
  • As per the Release Notesof ChromeDriver v2.35update the Chrome Browserversion to v62-64
  • Run CCleanertool to wipe off the OS chores before and after executing your Test Suite
  • If your base version of Chrome Browseris olden uninstall Chrome Browserthrough Revo Uninstallerand install a recent GA released version of Chrome Browser
  • Execute your Test.
  • Selenium Client版本更新到最新级别,即Selenium 3.9.1
  • ChromeDriver版本更新到最新级别,即ChromeDriver 2.35
  • 由于按照发行说明ChromeDriver v2.35更新的Chrome浏览器版本v62-64
  • 在执行测试套件之前和之后运行CCleaner工具以清除操作系统杂务
  • 如果您的Chrome 浏览器的基本版本较旧,请通过Revo Uninstaller卸载Chrome 浏览器并安装最新的 GA 发布版本的Chrome 浏览器
  • 执行您的测试

回答by Denzik

Selenium Standalone Server is currently on Build 3.9.1.

Selenium 独立服务器目前在 Build 3.9.1 上。

It looks like you're running an older version of the standalone server. Perhaps the ChromeDriver version you're running might function better with an update to your Selenium Standalone Server?

看起来您正在运行旧版本的独立服务器。也许您正在运行的 ChromeDriver 版本在更新您的 Selenium 独立服务器后可能会运行得更好?

http://www.seleniumhq.org/download/

http://www.seleniumhq.org/download/

Also, just to be sure... You have the latest version of the Windows Chrome Driver version? They're on 2.35 for the latest. https://chromedriver.storage.googleapis.com/index.html?path=2.35/

另外,为了确定...您有最新版本的 Windows Chrome 驱动程序版本吗?他们的最新消息是 2.35。 https://chromedriver.storage.googleapis.com/index.html?path=2.35/