Created
June 23, 2016 04:27
-
-
Save evert0n/fbd3cce83be3d0a81d3364e13231256e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
'use strict'; | |
/** | |
* Custom browser commands | |
*/ | |
var Commands = { | |
/** | |
* Login | |
* | |
* @param {String} username | |
* @param {String} password | |
* @param {String} url | |
* @return {Boolean} | |
*/ | |
login: function(username, password, url) { | |
if (undefined === username || undefined === password) { | |
return false; | |
} | |
if (undefined === url) { | |
url = this.options.baseUrl; | |
} | |
this.url(url); | |
this.setValue('//label[contains(., "Username")]/following::input[1]', username) | |
this.setValue('//label[contains(., "Password")]/following::input[1]', password) | |
this.click('button=Sign In'); | |
this.pause(1000); | |
return true; | |
}, | |
/** | |
* Logout | |
* | |
* @param {String} url | |
* @return {Boolean} | |
*/ | |
logout: function(url) { | |
if (undefined === url) { | |
url = this.options.baseUrl; | |
} | |
if (url.slice(-1) !== '/') { | |
url = url + '/'; | |
} | |
this.url(url + 'logout'); | |
this.pause(1000); | |
return true; | |
}, | |
/** | |
* Get access token | |
* | |
* @return {String} Access token | |
*/ | |
getAccessToken: function() { | |
var results = this.execute(function() { | |
return wizehive.token(); | |
}); | |
return results.value; | |
}, | |
/** | |
* Get scope | |
* | |
* @param {String} selector | |
* @return {Null|Object} | |
*/ | |
getScope: function(selector) { | |
var results = this.execute(function(selector) { | |
return angular.element(document.querySelector(selector)).scope(); | |
}); | |
return results.value; | |
}, | |
} | |
module.exports = Commands; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment