Permalink
Browse files

Moved session handling to Client#commandPath()

  • Loading branch information...
1 parent 6984849 commit dc21c8806129445dd839da0c05b43114d890fcd0 @tj tj committed Sep 3, 2010
Showing with 9 additions and 5 deletions.
  1. +1 −1 examples/google.js
  2. +8 −4 lib/soda/client.js
View
@@ -19,7 +19,7 @@ browser.session(function(err){
browser.command('assertTitle', ['Hello World - Google Search'], function(err, res){
if (err) throw err;
browser.command('testComplete', [], function(err, res){
- console.dir(res.body)
+ console.log('done!');
});
});
});
View
@@ -66,9 +66,6 @@ Client.prototype.command = function(cmd, args, fn){
// Path construction
var path = this.commandPath(cmd, args);
- if (this.sid && cmd !== 'getNewBrowserSession') {
- path += '&sessionId=' + this.sid;
- }
// Request
var req = client.request('GET'
@@ -105,9 +102,16 @@ Client.prototype.command = function(cmd, args, fn){
*/
Client.prototype.commandPath = function(cmd, args){
+ // Map the command arguments
args = args.map(function(arg, i){
return i + 1 + '=' + encodeURIComponent(arg);
- }).join('&');
+ }).join('&') + '&' + args;
+
+ // Ignore session id for getNewBrowserSession
+ if (this.sid && cmd !== 'getNewBrowserSession') {
+ args += '&sessionId=' + this.sid;
+ }
+
return '/selenium-server/driver/?cmd=' + cmd + '&' + args;
};

0 comments on commit dc21c88

Please sign in to comment.