Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
denvned opened this issue Feb 12, 2016 · 12 comments
Closed

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

denvned opened this issue Feb 12, 2016 · 12 comments
Labels

Comments

@denvned
Copy link

denvned commented Feb 12, 2016

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)

@jleyba
Copy link
Contributor

jleyba commented Feb 12, 2016

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

@denvned
Copy link
Author

denvned commented Feb 12, 2016

@jleyba, I create the driver using this code:

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

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

@jleyba
Copy link
Contributor

jleyba commented Feb 12, 2016

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]]}

@jleyba
Copy link
Contributor

jleyba commented Feb 13, 2016

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).

@jleyba jleyba closed this as completed Feb 13, 2016
@jhen0409
Copy link

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

Also, the core-js@2.0 is work well. (babel-polyfill still used 1.0)

@mekdev
Copy link

mekdev commented Mar 15, 2016

@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.

@ddavison
Copy link
Member

@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.

@jleyba
Copy link
Contributor

jleyba commented Mar 15, 2016

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

@mekdev
Copy link

mekdev commented Mar 15, 2016

@jleyba Thank you!

@mekdev
Copy link

mekdev commented Mar 15, 2016

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

@denvned
Copy link
Author

denvned commented Mar 15, 2016

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

Also, the core-js@2.0 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.

@nambir
Copy link

nambir commented Oct 7, 2016

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/

@lock lock bot locked and limited conversation to collaborators Aug 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants