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

  1. in nightwatch.json specify path folder contain custom command file
  2. create js file , name how custom command should names (ie login.js)
  3. 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;  };

  1. use custom command in test:

.login("your_username", "your_password")


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -