Mark Wilbur
Mark Wilbur

Reputation: 2915

How do you get webdriverjs working?

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!

Upvotes: 2

Views: 4147

Answers (1)

shawnzhu
shawnzhu

Reputation: 7585

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.

Upvotes: 5

Related Questions