量角器错误 - 无法启动 WebDriver 会话

Protractor ERROR - Unable to start a WebDriver session

我正在尝试 运行 http://angular.github.io/protractor/#/ 上的普通量角器示例。我已完成所有步骤,但出现以下错误。

我已经用 binary: "/Applications/Google\ Chrome.app"binary: "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" 尝试了 HERE and HERE 的解决方案,但都不起作用

我不太确定我还能配置什么;它似乎不起作用。关于我可以做些什么来让它工作有什么想法吗?

编辑 我可以在 http://localhost:4444/wd/hub 看到状态,所以不确定问题出在量角器配置还是 webdriver-manager。

webdriver-manager 错误:

Starting ChromeDriver 2.13.307650 (feffe1dd547ee7b5c16d38784cd0cd679dfd7850) on port 10276
Only local connections are allowed.
15:18:35.760 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.8.0_31'
Driver info: driver.version: unknown
  at java.util.concurrent.FutureTask.report(FutureTask.java:122)
  at java.util.concurrent.FutureTask.get(FutureTask.java:192)
  at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:175)
  at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:111)
  at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:88)
  at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:108)
  at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:57)`

量角器出错运行:

Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
ERROR - Unable to start a WebDriver session.
/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113
  var template = new Error(this.message);
                 ^
UnknownError: The process has not exited yet therefore no result is available ...
    at new bot.Error (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113:18)
    at Object.bot.response.checkResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
    at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:152:24
    at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
    at notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)
    at notifyAll (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:442:7)
    at resolve (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:420:7)
    at fulfill (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:535:5)
    at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
    at notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)
    at notifyAll (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:442:7)
    at resolve (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:420:7)
    at [object Object].fulfill (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:535:5)
    at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:721:49
    at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/http/http.js:96:5
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:131:7)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:943:16
    at process._tickCallback (node.js:419:13)
==== async task ====
WebDriver.createSession()
    at Function.webdriver.WebDriver.acquireSession_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:149:22)
    at Function.webdriver.WebDriver.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:123:30)
    at [object Object].Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:294:22)
    at [object Object].DriverProvider.getNewDriver (/usr/local/lib/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
    at [object Object].Runner.createBrowser (/usr/local/lib/node_modules/protractor/lib/runner.js:180:37)
    at /usr/local/lib/node_modules/protractor/lib/runner.js:246:21
    at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:797:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:826:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:759:13)
    at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:573:44
    at flush (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:419:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:906:3
[launcher] Process exited with error code 1`

通过改用 Firefox,我能够将其缩小为 finding/initializing Chrome 的问题:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js'],
  capabilities: {
        'browserName': 'firefox'
  },
}

此配置工作正常并在 FF 中运行测试。

然后我一直在寻找这个线程:https://github.com/angular/protractor/issues/1424 发现 chromedriver 有时会出现兼容性问题。

所以我尝试了在 http://chromedriver.storage.googleapis.com/index.html 找到的不同版本,最终将 /usr/local/lib/node_modules/protractor/selenium/chromedriver 的最新版本 (2.13) 替换为早期版本 (2.9)。

这帮我解决了。

更新

看起来安装较新的 Chrome 驱动程序版本 2.15 也可以解决这个问题

我去了类似的问题

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
...
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
    at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:74)
    at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:165)
    at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:183)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:170)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
    at 

并将 chromedriver 从 2.14 降级到 2.9 解决了这个问题。 Windows 2008 R2 Ent,Chrome 版本 41.0.2272.101 m。奇怪的是,在 'identical' 系统上它与 chromedrive 2.14 一起工作。又一个发现。设置 -Dwebdriver.chrome.logfile=chromedriver.log 为 2.14 生成空日志,而 2.9 写入日志正常