Skip to content

Instantly share code, notes, and snippets.

@sebv
Created June 29, 2015 16:05
Show Gist options
  • Save sebv/1c638fad003e58a66f72 to your computer and use it in GitHub Desktop.
Save sebv/1c638fad003e58a66f72 to your computer and use it in GitHub Desktop.
require('colors');
var wd;
try {
wd = require('wd');
} catch( err ) {
wd = require('../../lib/main');
}
var browser = wd.promiseChainRemote();
// optional extra logging
browser.on('status', function(info) {
console.log(info.cyan);
});
browser.on('command', function(eventType, command, response) {
console.log(' > ' + eventType.cyan, command, (response || '').grey);
});
browser.on('http', function(meth, path, data) {
console.log(' > ' + meth.magenta, path, (data || '').grey);
});
/* jshint evil: true */
browser
.init({browserName:'firefox'})
.get("http://admc.io/wd/test-pages/guinea-pig.html")
.elementById('i_am_a_textbox').type('Something Cool')
.sleep(1000)
.elementById('i_am_a_textbox').keys([wd.SPECIAL_KEYS.Meta, 'a'])
.sleep(1000)
.elementById('i_am_a_textbox').keys(['x', wd.SPECIAL_KEYS.NULL])
.sleep(1000)
.elementById('comments').click()
.keys([wd.SPECIAL_KEYS.Meta, 'v', wd.SPECIAL_KEYS.NULL])
.sleep(5000)
.fin(function() { return browser.quit(); })
.done();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment