0 votes
1 view
in Devops and Agile by (22.5k points)

I am looking to create reusable components within my nightwatch.js tests.

ie. login to the web app, logout of the web app

What is the best method/pattern for creating these steps in a reusable way?

1 Answer

0 votes
by (57.5k points)

You can create custom commands for that: http://nightwatchjs.org/guide#writing-custom-commands

  • in nightwatch.json specify the path to the folder which will contain your custom command file
  • create a js file and name it how your custom command ought to be named (ie login.js)
  • write the code you need:

exports.command = function(username, password) ;

Use the custom command in your test:

.login("your_username", "your_password")

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...