soda: Selenium adapter for Node.js
Soda the latest project from LearnBoost, brings Selenium RC to Node.js.
Install Soda via npm
$ npm install soda
and with your Selenium server running you can run an example in your Node app with:
$ node examples/my_example.js
As with most everything Node, example actions are callback-driven:
browser.session(function(err){
browser.open('/', function(err, body, res){
browser.type('q', 'Hello World', function(err, body, res){
browser.testComplete(function(){
});
});
});
});
To keep your code from looking like a set of Matryoshka dolls, Soda supports chaining:
browser
.chain
.session()
.open('/')
.type('q', 'Hello World')
.testComplete()
.end(function(err){
if (err) throw err;
console.log('done');
});
Testing in the cloud
With Saucelabs, you can even move your acceptance testing to the cloud:
var soda = require('soda')
, assert = require('assert');
var browser = soda.createSauceClient({
'url': 'http://sirrobertborden.ca.app.learnboost.com/'
, 'username': '<your username>'
, 'access-key': '<your api key>'
, 'os': 'Linux'
, 'browser': 'firefox'
, 'browser-version': '3.'
, 'max-duration': 300 // 5 minutes
});
Keep an eye on the README and API docs for more advanced examples.
Discussion
Sign in or Join to comment or subscribe