2

Anyone here have experience using Selenium and webdriverjs? I'm coming from a non-Java background with a good deal of experience with Node.js and JavaScript in general. According to the Selenium docs, you have to set-up a stand-alone Selenium server to use the node web driver. Fortunately, they seem to be bundled together.

npm install webdriverjs

gets you the JAR file for the standalone selenium server inside the node_modules/webdriverjs/bin directory. Example tests are inside the node node_modules/webdriverjs/examples directory but the tests in them fail when I run them from either the webdriverjs or examples directories.

What's the missing piece here? What's the quickest way to get up and running?

I have read the docs.

Note: Stack overflow wouldn't let me use the tag webdriverjs, but this is specifically about webdriverjs, not using selenium with Java or other languages.

Update: The only problem was that the built-in example tests are broken!

Mark Wilbur
  • 2,809
  • 2
  • 23
  • 22
  • is there any error message indicates errors or blocking issue? as default, the webdrivejs uses the local selenium standalone server which listens to http://localhost:4444/wd/hub. – shawnzhu Aug 20 '13 at 05:07

1 Answers1

5

Here's what I did to get webdriverjs working:

Step 1: start selenium standalone in my laptop by running command java -jar selenium-server-standalone-2.33.0.jar. then it will listen to http://localhost:4444/ and you can access it via http://localhost:4444/wd/hub/. You also need to make sure Firefox browser is installed on your laptop.

Step 2: create a new directory and run command npm install webdriverjs.

Step 3: create a new file named test_webdriverjs.js in the new directory you created, and it looks like this:

var webdriverjs = require('webdriverjs');

var client = webdriverjs.remote({
    host: 'localhost',
    port: 4444
});

client.init();

client.url('https://github.com/')
  .getTitle(function(err, title) { console.log (title)}).call(function () {});

client.end();

Then run command node test_webdriverjs.js under the same directory and you will find it works. If it doesn't work, paste out the console output.

shawnzhu
  • 7,233
  • 4
  • 35
  • 51
  • Interesting. This got me up and going, and the issue was with the built-in mocha tests, not installation! Your step zero is superfluous since as I said in the question, the webdriver npm package includes the standalone selenium server. Here's the quickest way to get up and going: Step one—Install webdriverjs: `npm install webdriverjs` Step two—Run the stand-alone selenium server that was part of the install bundle: `java -jar node_modules/webdriverjs/bin/selenium-server-standalone-2.31.0.jar` Step 3—Use shawnzhu's test file; the built-in example tests are broken. – Mark Wilbur Aug 20 '13 at 18:52