Skip to content

Instantly share code, notes, and snippets.

@admc
Created October 30, 2012 00:31
Show Gist options
  • Save admc/3977571 to your computer and use it in GitHub Desktop.
Save admc/3977571 to your computer and use it in GitHub Desktop.
Example
var webdriver = require('wd');
var assert = require('assert');
var browser = webdriver.remote("ondemand.saucelabs.com", 80, "admc", "key");
browser.on('status', function(info){
console.log('\x1b[36m%s\x1b[0m', info);
});
browser.on('command', function(meth, path){
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path);
});
browser.init({
browserName:'chrome'
, tags : ["examples"]
, name: "This is an example test"
, "max-duration": 299
, "command-timeout": 299
, "idle-timeout": 299
}, function() {
browser.get("http://saucelabs.com/test/guinea-pig", function() {
browser.title(function(err, title) {
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!');
browser.elementById('submit', function(err, el) {
browser.clickElement(el, function() {
browser.eval("window.location.href", function(err, title) {
assert.ok(~title.indexOf('#'), 'Wrong title!');
browser.quit()
})
})
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment