selenium-webdriver for Node.js gives an error when using ChromeDriver

Created on 12 Feb 2016  路  12Comments  路  Source: SeleniumHQ/selenium

The latest version (2.52.0) of selenium-webdriver for Node.js produces the following error when used with different versions of ChromeDriver:

WebDriverError: unknown error: cannot find dict 'desiredCapabilities'
(Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 3.13.0-58-generic x86_64)
at WebDriverError (node_modules/selenium-webdriver/error.js:27:10)
at Object.checkLegacyResponse (node_modules/selenium-webdriver/error.js:580:13)
at node_modules/selenium-webdriver/lib/webdriver.js:64:13
at Promise.invokeCallback_ (node_modules/selenium-webdriver/lib/promise.js:1329:14)
at TaskQueue.execute_ (node_modules/selenium-webdriver/lib/promise.js:2790:14)
at TaskQueue.executeNext_ (node_modules/selenium-webdriver/lib/promise.js:2773:21)
at node_modules/selenium-webdriver/lib/promise.js:2652:27
at node_modules/selenium-webdriver/lib/promise.js:639:7
at run (node_modules/babel/node_modules/babel-core/node_modules/core-js/modules/es6.promise.js:104:47)
at node_modules/babel/node_modules/babel-core/node_modules/core-js/modules/es6.promise.js:115:28
at flush (node_modules/babel/node_modules/babel-core/node_modules/core-js/modules/$.microtask.js:19:5)
From: Task: WebDriver.createSession()
at acquireSession (node_modules/selenium-webdriver/lib/webdriver.js:62:22)
at Function.createSession (node_modules/selenium-webdriver/lib/webdriver.js:295:12)
at Driver (node_modules/selenium-webdriver/chrome.js:778:38)
at Builder.build (node_modules/selenium-webdriver/builder.js:464:16)
at Context.initWebDriver (init/web/driver.js:11:6)
at ChildProcess. (init/common/server.js:28:7)
at handleMessage (internal/child_process.js:686:10)
at Pipe.channel.onread (internal/child_process.js:440:11)
From: Task: WebDriver.navigate().to(http://localhost:3000)
at Driver.schedule (node_modules/selenium-webdriver/lib/webdriver.js:344:17)
at Navigation.to (node_modules/selenium-webdriver/lib/webdriver.js:998:25)
at Driver.get (node_modules/selenium-webdriver/lib/webdriver.js:771:28)
at Context. (test/web/header.js:5:27)
From: Task: WebDriver.quit()
at Driver.schedule (node_modules/selenium-webdriver/lib/webdriver.js:344:17)
at Driver.quit (node_modules/selenium-webdriver/lib/webdriver.js:419:23)
at Context.shutdownWebDriver$ (init/web/driver.js:16:18)
at tryCatch (node_modules/babel/node_modules/babel-core/node_modules/regenerator/runtime.js:61:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as next
at invoke (node_modules/babel/node_modules/babel-core/node_modules/regenerator/runtime.js:136:37)
at callInvokeWithMethodAndArg (node_modules/babel/node_modules/babel-core/node_modules/regenerator/runtime.js:172:16)
at previousPromise (node_modules/babel/node_modules/babel-core/node_modules/regenerator/runtime.js:194:19)
at new Promise (node_modules/babel/node_modules/babel-core/node_modules/core-js/modules/es6.promise.js:197:7)
at AsyncIterator.enqueue (node_modules/babel/node_modules/babel-core/node_modules/regenerator/runtime.js:193:13)
at AsyncIterator.prototype.(anonymous function) as next
at Object.runtime.async (node_modules/babel/node_modules/babel-core/node_modules/regenerator/runtime.js:215:14)
at Context.shutdownWebDriver (init/web/driver.js:14:43)
at ChildProcess. (init/common/server.js:47:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)

C-nodejs

All 12 comments

How are you creating your driver? I am unable to reproduce this using chromedriver 2.19 and 2.21

@jleyba, I create the driver using this code:

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder()
    .forBrowser('chrome')
    .build();

Looks like babel is rewriting code in a way that is breaking capabilities serialization.

Without Babel:

[2016-02-12T18:13:50Z] [FINER] [webdriver.http.Executor] >>>
POST /session HTTP/1.1
accept: application/json; charset=utf-8

{"desiredCapabilities":{"browserName":"chrome"}}

With Babel:

[2016-02-12T18:11:19Z] [FINER] [webdriver.http.Executor] >>>
POST /session HTTP/1.1
accept: application/json; charset=utf-8

{"desiredCapabilities":[["browserName","chrome"],["version",null],["platform",null]]}

Looks like Babel breaks a handful of other classes when they are converted to ES5.

ES6 class syntax is fully supported in Node v4.2.x, which is the minimum supported version of Node. You should configure Babel to not translate ES6 classes (in other words, don't use babel-preset-es2015).

When I don't use core-js (included to babel-polyfill), It work. :)

Also, the [email protected] is work well. (babel-polyfill still used 1.0)

@jleyba, I am glad I found this. Is it recommended that we do not use babel with the official selenium lib (at least in the short term) ?

We just started pulling babel into our stack but only started to use imports/destructuring features.

Our stack is mocha + promise manager adding in babel-preset-es2015 and "presets": ["es2015"] in .babelrc

I would really appreciate it any input to help us avoid any headaches in the foreseeable term.

@mekdev babel is just a polyfill, so there shouldn't be any problem using it, as long as you use the right version, as @jleyba mentioned.

I've been using the following in my .babelrc without any problems:

{
  "plugins": [
    "transform-es2015-parameters",
    "transform-es2015-modules-commonjs",
    "transform-es2015-shorthand-properties",
    "transform-es2015-spread",
    "transform-object-rest-spread",
  ]
}

You could also try setting the ignore option to exclude files under selenium-webdriver

@jleyba Thank you!

@ddavison Its always good to run into you here, hope to see you at the next seconf :)

When I don't use core-js (included to babel-polyfill), It work. :)

Also, the [email protected] is work well. (babel-polyfill still used 1.0)

This probably means that using babel-runtime together with transform-runtime instead of using babel-polyfill should help. I am not working with _selenium-webdriver_ at the moment, and cannot verify. Maybe somebody else can do it?

You could also try setting the ignore option to exclude files under selenium-webdriver

No, this won't help, as Babel already ignores _node_modules_ by default.

Try this link. Which has the working automated testing project sample.
Which has the code for accessing all ASP.NET and telerik controls.

https://nambithecoder.com/2016/10/06/automated-testing-solution/

Was this page helpful?
0 / 5 - 0 ratings