diff --git a/Readme.md b/Readme.md index 69d5b7b..bd9f80a 100644 --- a/Readme.md +++ b/Readme.md @@ -60,10 +60,11 @@ When chaining successful commands may receive a callback, which is useful for cu .getTitle(function(title){ assert.equal('Hello World', title); }) - .and(function(){ + .and(function(browser){ // arbitrary callback - // do whatever you need, "this" - // is the client + // do whatever you need, "this" / the first arg + // are the Client instance + this.assertElementPresent('css=foo'); }) .testComplete() .end(function(err){ diff --git a/lib/soda/client.js b/lib/soda/client.js index c4c8370..0c7428e 100644 --- a/lib/soda/client.js +++ b/lib/soda/client.js @@ -220,7 +220,7 @@ Client.prototype.enqueue = function(cmd, args, fn){ }; /** - * Queue an arbitrary callback `fn` when using the chaining api. + * Arbitrary callback `fn(this)` when using the chaining api. * * @param {Function} fn * @return {Client} @@ -228,11 +228,7 @@ Client.prototype.enqueue = function(cmd, args, fn){ */ Client.prototype.and = function(fn){ - var self = this; - this.queue.push(function(){ - fn.call(self); - self.queue.shift()(); - }); + fn.call(this, this); return this; }; diff --git a/lib/soda/index.js b/lib/soda/index.js index ddfb9cc..f92e36f 100644 --- a/lib/soda/index.js +++ b/lib/soda/index.js @@ -24,4 +24,4 @@ exports.createSauceClient = require('./sauce').createClient; * @type String */ -exports.version = '0.0.2'; +exports.version = '0.1.0'; diff --git a/package.json b/package.json index f7d30e8..9ba21de 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "soda", "description": "Selenium RC Node Adapter (with Saucelabs support)", - "keywords": ["selenium", "saucelabs", "testing"], - "version": "0.0.2", + "keywords": ["selenium", "saucelabs", "testing", "test", "tests"], + "version": "0.1.0", "author": "TJ Holowaychuk ", "main": "./lib/soda/index.js", "engines": { "node": ">= 0.2.0" } diff --git a/test/client.test.js b/test/client.test.js index 557daa2..c06c669 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -96,10 +96,11 @@ module.exports = { .chain .session() .open('/') - .assertTitle('Google') - .and(function(){ + .and(function(browser){ ++called; + assert.equal(browser, client, 'and() first arg is not the client'); assert.equal(this, client, 'and() "this" is not the client'); + this.assertTitle('Google'); }) .testComplete() .end(function(err){