WebDriver/Selenium 2 node.js client

WD.js -- A light weight WebDriver/Se2 client for node.js


npm install wd-parallel
  • License - Apache 2: http://www.apache.org/licenses/LICENSE-2.0

Start by importing the required library.

try {
  p_webdriver = require('wd-parallel');
} catch( err ) { 
  p_webdriver = require('../lib/main');

Then create a default multiple browser object.

var browsers = p_webdriver.remote();

Now add a test method to the multiple browser object. This method needs to arguments named browser and desired.

  • This method contains your test logic.
  • Test should be run as if to be run on an object named browser.
browsers.test = function(browserdesired) {
    console.log("server status:", browser.status());
    console.log("title is "+browser.title());
    var queryField = browser.elementByName('q');
    browser.type(queryField, "Hello World");
    browser.type(queryField, "\n");
    browser.elementByCss('#ires'); // waiting for new page to load 

Load the configuration for all your browsers from your configuration file.

//Load configuration file 

Now you can go ahead and run the test !

//Run test on all browsers 

This uses node-wd-sync written by sebv so you can check this page on supported methods.

full mapping

WD is simply implementing the Selenium JsonWireProtocol, for more details see the official docs:
 - http://code.google.com/p/selenium/wiki/JsonWireProtocol