wd-series

Async wrapper for wd.js

wd-series

Async wrapper for admc/wd (the Node WebDriver client).

With vanilla Wd.js, you can do amazing things like this:

var driver = wd.remote();
driver.init(desiredCaps, function(errsessionId) {
  driver.get("http://mysite.com", function(err) {
    driver.elementById("someId", function(errel) {
      el.click(function(err) {
        driver.elementById("anotherThing", function(errel2) {
          el2.text(function(errtext) {
            // assert text is correct 
          });
        });
      });
    });
  });
});

Using wd-series, you can make it line up more nice-like:

npm install wd-series
var driver = wd.remote(),
    driverSeries = require('wd-series');
 
driverSeries(driver, [
  function() { this.init(desiredCaps); },
  function() { this.get("http://mysite.com"); },
  function() { this.elementById("someId"); },
  function() { this.res.click(); },
  function() { this.elementById("anotherThing"); },
  function() { this.res.text() },
  function() { /* assert text is correct */ this.next(); }
]);

It looks even more compact in coffee-script!

driver = wd.remote()
driverSeries = require 'wd-series'
 
driverSeries driver,
    -> @init desiredCaps
    -> @get "http://mysite.com"
    -> @elementById "someId"
    -> @res.click()
    -> @res.text()
    -> @next() # assert text is correct 

Enjoy. Pull requests. Etc.