Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better error message

  • Loading branch information...
commit 8509fe8da6bd824bc4b92a6e637f380b7eabc3f9 1 parent a32f8f8
TJ Holowaychuk tj authored
Showing with 15 additions and 4 deletions.
  1. +12 −3 examples/google.js
  2. +3 −1 lib/selenium/client.js
15 examples/google.js
View
@@ -14,9 +14,18 @@ var browser = selenium.createClient({
browser.session(function(err){
browser.command('open', ['/'], function(err, res){
- console.dir(res.body)
- browser.command('testComplete', [], function(err, res){
- console.dir(res.body)
+ browser.command('type', ['q', 'Hello World'], function(err, res){
+ browser.command('click', ['btnG'], function(err, res){
+ browser.command('assertTitle', ['Google'], function(err, res){
+ if (err) throw err;
+ browser.command('assertTextPresent', ['Hello'], function(err, res){
+ if (err) throw err;
+ browser.command('testComplete', [], function(err, res){
+ console.dir(res.body)
+ });
+ });
+ });
+ });
});
});
});
4 lib/selenium/client.js
View
@@ -81,7 +81,9 @@ Client.prototype.command = function(cmd, args, fn){
res.on('data', function(chunk){ res.body += chunk; });
res.on('end', function(){
if (res.body.indexOf('ERROR') === 0) {
- fn(new Error(res.body), res);
+ var err = res.body.replace(/^ERROR: */, '');
+ err = ['command:', cmd, args.join(', '), err].join(' ');
+ fn(new Error(err), res);
} else {
if (res.body.indexOf('OK') === 0) {
res.body = res.body.replace('OK,', '');
Please sign in to comment.
Something went wrong with that request. Please try again.