我试图在我的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: ServletContext@o.s.j.s.ServletContextHandler@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
之后我打开了一个新的命令行提示符并运行了我的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);
});
这是我得到的错误
{ 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' } }
有人可以向我解释我在这里做错了什么吗?也是的,我已经通过npm以及wdio-chromedriver-service安装了chromedriver。
答案 0 :(得分:4)
您看到的错误确实给了我们一些关于错误的提示,如下所示:
{ 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' }
从错误消息中可以清楚地看到 ChromeDriver 未被检测到,因为您将日志消息视为驱动程序信息:driver.version:unknown
。出现此错误的主要原因可能是您正在使用的二进制文件之间不兼容。
快速解决方案是:
答案 1 :(得分:3)
通过webdriver-manager更新您的ChromeDriver版本,如下所示:
const Buffer = require("buffer").Buffer;
let encodedAuth = new Buffer("your text").toString("base64");
这将删除较旧的版本,使用内置配置中所述的最新版本进行更新,然后重新启动服务器。希望这会有所帮助。
答案 2 :(得分:3)
启动网格节点时,请确保 -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
答案 3 :(得分:0)
Selenium Standalone Server目前在Build 3.9.1上。
看起来您正在运行旧版本的独立服务器。也许你正在运行的ChromeDriver版本可能会更新你的Selenium Standalone Server吗?
http://www.seleniumhq.org/download/
另外,只是为了确定...您拥有最新版本的Windows Chrome驱动程序版本?最新的是2.35。 https://chromedriver.storage.googleapis.com/index.html?path=2.35/
答案 4 :(得分:0)
(2020年更新)
如果您正在运行Selenium Server 4 Alpha,则无需通过命令行设置chromedriver.exe路径,只需确保chromedriver exe文件与jar文件位于同一文件夹中
我花了很多时间才知道Selenium Server默认不包括Web驱动程序(Firefox,Chrome等),不,它们需要单独下载。