Build a QA Automation Test Framework in 10 mins.. Step-by-Step Installation guide for Javascript Selenium based Nightwatch.js

Nov 13, 2017 · 3 min read

Target Audience for Beginners, Manual QA testers, SDET, Business Analysts and Front-end developers.

Automation testing framework can help save testing time and manual efforts as well as setup Continuous Integration.

  • Why Selenium?
    Core Open-Source API to automate browsers and Mobile applications..
  • Why Javascript?
    Lightweight, easy to maintain, quick setup!
  • Why Automation?
    Perform manual and repetitive tasks very quickly and efficiently by letting the Robots do the work!

Installation Steps

  1. Create a new folder
  • Create a new folder for example newTestFramework

2. Create a file called — nightwatch.js input this line


  • In your Terminal run the command npm init this will create a package.json file.
  • Press Enter for all questions.

4. Now we will install nightwatch using npm

  • Run command in terminal — npm install nightwatch —- save

5. Make new folders — mkdir pages tests lib




Stanalone Jar file.

7. Download the latest version of Chrome Driver — For window Make sure to download chromedriver.exe

8. From Downloaded folder, move both files — Selenium-Standalone-3.x.x. jar and chromedriver to /lib directory on your project.

9. Create and Copy followingnightwatch.json and paste into your project. (source

"src_folders": ["tests"],
"output_folder": "reports/XMLReports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "pages",
"selenium": {
"start_process": true,
"server_path": "lib/drivers/selenium-server-standalone-3.8.1.jar",
"start_session": true,
"log_path": "log/",
"host": "",
"port": 4444,
"cli_args": {
"": "lib/drivers/chromedriver"
"test_settings" : {
"chrome": {
"launch_url": "http://localhost",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": false,
"path": "screenshots/Chrome/"
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [

"edge" : {
"desiredCapabilities": {
"browserName": "MicrosoftEdge"

10. Set path for selenium and chrome driver in nightwatch.json.

13. Change the start_process:true

14. Create a example file lets call it google.js

  • Insert the code
module.exports = {   tags: ['google'],   'Demo test Google' : function (browser) {        browser         .url('') // Go to a url        .waitForElementVisible('body', 1000) // wait till page loads        .assert.title('Google') // Make sure Site title matches        .assert.visible('input[type=text]')         .setValue('input[type=text]', 'nightwatchjs') // send values        .click('button[name=btnG]') // click on search box        .pause(1000)        .end();      }};// = comment not necessary for code

15. Finally! We’re ready to Run our Tests.

  • In your terminal you can run — node nightwatch -e chrome -a tagname

In 15 steps we have a basic set up of Testing Framework.

On the Next entry, we can learn how to build build Continuous Integration much more in depth testing using night watch features.

For Complete Build Test Framework in JavaScript — Visit my Video Tutorial Course on Udemy —

Javascript Testing

All things Testing, Javascript and Node.js


Written by


QA Automation Testing Engineer..Love to automate the Web and make Testing Frameworks with Selenium and Javascript

Javascript Testing

All things Testing, Javascript and Node.js

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade