I am having some trouble setting up Selenium WebDriverJS. My goal is to run selenium tests on Chrome browser using Javascript (node).
I am following the instructions on https://code.google.com/p/selenium/wiki/WebDriverJs as well as https://code.google.com/p/chromedriver/wiki/GettingStarted
First I downloaded the chromedriver, and ran it on a terminal:
$ ./chromedriver
Starting ChromeDriver (v2.2) on port 9515
And then, I installed selenium-webdriver:
$ npm install selenium-webdriver
npm http GET https://registry.npmjs.org/selenium-webdriver
npm http 304 https://registry.npmjs.org/selenium-webdriver
selenium-webdriver@2.35.0 node_modules/selenium-webdriver
Then, I started node console and tried to build the webdriver instance
$ node
> var webdriver = require('selenium-webdriver')
undefined
> var driver = new webdriver.Builder().usingServer('http://localhost:9515/wd/hub').withCapabilities(webdriver.Capabilities.chrome()).build();
undefined
>
timers.js:103
if (!process.listeners('uncaughtException').length) throw e;
^
UnknownCommandError: unknown command: wd/hub/session
at new bot.Error (/selenium/node_modules/selenium-webdriver/lib/atoms/error.js:109:18)
at Object.bot.response.checkResponse (/selenium/node_modules/selenium-webdriver/lib/atoms/response.js:103:11)
at /selenium/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:133:20
at /selenium/node_modules/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/selenium-webdriver/lib/webdriver/promise.js:1438:20)
at notify (/selenium/node_modules/selenium-webdriver/lib/webdriver/promise.js:328:12)
at notifyAll (/selenium/node_modules/selenium-webdriver/lib/webdriver/promise.js:297:7)
at fulfill (/selenium/
And now I am blocked. Can someone help me on this, please? What am I missing here?
Thanks
Couple of things here.
By default, the chromedriver server handles commands at /, not /wd/hub. So you should be able to do:
If you want the chromedriver to have the same signature as the standalone Selenium server, start it with
--url-base=/wd/hub
.There's no need to start the chromedriver yourself - selenium-webdriver will do it for you if you request Chrome and omit a server location (make sure chromedriver can be found on your system
PATH
):