module.exports = {
"High level test" : function(browser){
browser
.login('username','password')
.fillForms('data')
.logout()
.end()
}
}module.exports = {
"Login, click around" : function (browser){
browser
.login('username','password') <<<< Custom command that runs a set of common tests.
.click('#button')
.end();
}
}
login.js:
exports.command = function( username, password, callback ){
var self = this;
this.execute(
function(username, password){
browser //<<<<<<<<<<< Is the nightwatch 'browser'/'client' context available here?
.setValue('input.username', username) //<<<< Are nightwatch commands available in this context?
.setValue('input.password', password)
.click('button.submit');
return true;
}, [username, password],
function(result) {
callback.call(this, result)
});
return this;
}exports.command = function(username, password, callback) {module.exports = { "Log in, click around." : function (browser) { browser
.url("http://localhost/app.html") .login('USERNAME', 'PASSWORD')
//At this point I've already logged in, with one command.
.assert.containsText('#main', 'Welcome!')
.end();
}
}