Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Client#open()

  • Loading branch information...
commit 061033282c25c93c3d70742339bdc7ce8e493a3b 1 parent 17884e1
@tj tj authored
Showing with 17 additions and 2 deletions.
  1. +2 −2 examples/google.js
  2. +15 −0 lib/soda/client.js
View
4 examples/google.js
@@ -13,13 +13,13 @@ var browser = soda.createClient({
});
browser.session(function(err){
- browser.command('open', ['/'], function(err, res){
+ browser.open('/', function(err, res){
browser.command('type', ['q', 'Hello World'], function(err, res){
browser.command('clickAndWait', ['btnG'], function(err, res){
browser.command('assertTitle', ['Hello World - Google Search'], function(err, res){
if (err) throw err;
browser.command('testComplete', [], function(err, res){
- console.log('done!');
+ console.log('done');
});
});
});
View
15 lib/soda/client.js
@@ -58,6 +58,7 @@ Client.prototype.session = function(fn){
* @param {String} cmd
* @param {Array} args
* @param {Function} fn
+ * @return {Client} for chaining
* @api private
*/
@@ -91,6 +92,7 @@ Client.prototype.command = function(cmd, args, fn){
});
});
req.end();
+ return this;
};
/**
@@ -120,6 +122,19 @@ Client.prototype.commandPath = function(cmd, args){
};
/**
+ * Open the given `url`.
+ *
+ * @param {String} url
+ * @param {Function} fn
+ * @return {Client}
+ * @api public
+ */
+
+Client.prototype.open = function(url, fn){
+ return this.command('open', [url], fn);
+};
+
+/**
* Shortcut for `new selenium.Client()`.
*
* @param {Object} options
Please sign in to comment.
Something went wrong with that request. Please try again.