Skip to content

Instantly share code, notes, and snippets.

@sebv
Created January 7, 2014 02:53
Show Gist options
  • Save sebv/8293982 to your computer and use it in GitHub Desktop.
Save sebv/8293982 to your computer and use it in GitHub Desktop.
wd async error handling
require('colors');
var wd;
try {
wd = require('wd');
} catch( err ) {
wd = require('../../lib/main');
}
var browser = wd.remote();
// optional extra logging
browser.on('status', function(info) {
console.log(info.cyan);
});
browser.on('command', function(meth, path, data) {
console.log(' > ' + meth.yellow, path.grey, data || '');
});
browser.init({browserName:'chrome'}, function() {
browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function() {
browser.waitForElementById('i don\'t exist', function(err, el) {
console.log('got error -->', err);
});
});
});
// CONSOLE OUTPUT
//
// node examples/async/async-error-handling.js
// Driving the web on session: 897bd93f-891d-4f72-ad11-bb4b69ea6b38
// > POST /session/:sessionID/url { url: 'http://admc.io/wd/test-pages/guinea-pig.html' }
// > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' }
// > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' }
// > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' }
// > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' }
// > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' }
// > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' }
// > POST /session/:sessionID/elements { using: 'id', value: 'i don\'t exist' }
// got error --> [Error: Element condition wasn't satisfied!]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment