Skip to content

Instantly share code, notes, and snippets.

@felipebn
Created January 31, 2018 15:02
Show Gist options
  • Save felipebn/bc3ef59e8c30e4263739377fcc53eaa2 to your computer and use it in GitHub Desktop.
Save felipebn/bc3ef59e8c30e4263739377fcc53eaa2 to your computer and use it in GitHub Desktop.
Sample nightwatch.js assertion in multiple items
module.exports = {
url: 'http://google.com',
elements: {
searchBar: {
selector: 'input[type=text]'
},
btn: {
selector: 'input[type=submit]',
}
},
commands: [
{
assertBtnText: function(index, text){
var i = index + 1
return this.getValue(`input[type=submit]:nth-child(${i})`, function(result){
this.assert.equal(result.value, text)
});
}
}
]
};
module.exports = {
'Test': function (client) {
var google = client.page.google();
google.navigate()
.assert.title('Google')
.assert.visible('@searchBar')
.setValue('@searchBar', 'nightwatch');
google.assertBtnText(0,"Pesquisa Google")
google.assertBtnText(1,"Sinto-me com sorte")
client.end();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment