Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Checking the response body for ^ERROR

  • Loading branch information...
commit 83f243b49cad5d1a3b363dd9e00b9f08c7d398fa 1 parent 1543c1e
TJ Holowaychuk tj authored
Showing with 11 additions and 3 deletions.
  1. +3 −2 examples/google.js
  2. +8 −1 lib/selenium/client.js
5 examples/google.js
View
@@ -11,6 +11,7 @@ var client = selenium.createClient({
url: 'http://www.google.com'
});
-client.command('getNewBrowserSession', ['*firefox', 'http://google.com'], function(){
-
+client.command('getNewBrowserSessions', ['*firefox', 'http://google.com'], function(){
+ console.dir(arguments[0])
+ console.dir(arguments[1].body)
});
9 lib/selenium/client.js
View
@@ -38,10 +38,17 @@ Client.prototype.command = function(name, args, fn){
, this.commandURL(name, args)
, { Host: this.host + (this.port ? ':' + this.port : '') });
req.on('response', function(res){
+ console.dir(res.statusCode)
res.body = '';
res.setEncoding('utf8');
res.on('data', function(chunk){ res.body += chunk; });
- res.on('end', function(){ fn(null, res); });
+ res.on('end', function(){
+ if (res.body.indexOf('ERROR') === 0) {
+ fn(new Error(res.body), res);
+ } else {
+ fn(null, res);
+ }
+ });
});
req.end();
};
Please sign in to comment.
Something went wrong with that request. Please try again.