node.js - Can I create reusable test steps in nightwatch.js? -
i looking create reusable components within nightwatch.js
tests.
ie. login web app, logout of web app
what best method / pattern creating these steps in reusable way?
you can create custom commands that: http://nightwatchjs.org/guide#writing-custom-commands
- in nightwatch.json specify path folder contain custom command file
- create js file , name how custom command should names (ie login.js)
- write code need:
exports.command = function(username, password) { .waitforelementvisible('#password', 4000) .setvalue('#password', password) .waitforelementvisible('#username', 1000) .setvalue('#username', username) .waitforelementvisible('#sign_in', 1000) .click('#sign_in') .waitforelementvisible('h1.folder-title', 10000) return this; };
- use custom command in test:
.login("your_username", "your_password")
Comments
Post a Comment