Created
March 13, 2014 16:42
-
-
Save bryanwb/9532032 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('colors'); | |
var chai = require("chai"); | |
var chaiAsPromised = require("chai-as-promised"); | |
chai.use(chaiAsPromised); | |
chai.should(); | |
var wd = require('wd'); | |
// enables chai assertion chaining | |
chaiAsPromised.transferPromiseness = wd.transferPromiseness; | |
var browser = wd.promiseChainRemote(); | |
wd.addPromiseChainMethod( | |
'login', | |
function() { | |
return this.eval('window.location.pathname', function(err, pathname) { | |
console.log('inside my promise'); | |
if (pathname == '/login'){ | |
return this.elementById('username').type('admin') | |
.elementByCss('input[name=password]').type('admin') | |
.elementByCss('input[name=remember_me]').click() | |
.elementByCss('input[name=submit]').click(); | |
} else { | |
return this; | |
} | |
}); | |
}); | |
browser | |
.init({browserName:'chrome'}) | |
.get('http://localhost:8080/manage') | |
.login() | |
.elementById('name').type('local_endpoint') | |
.elementById('type').type('Host') | |
.elementById('agreeTerms').click() | |
.elementByCss('input[name=Save]', function(err, elements){ | |
elements[0].click(); | |
}) | |
// .fin(function() { return browser.quit(); }) | |
.done(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment