Skip to content

Corefinder89/Nightwatch-Automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nightwatch-Automation

Let me guide my followers in installing and use Nightwatch for automation.

Nightwatch.js is an end to end testing framework that has been derived from the node.js library.
Like any other automation process Nightwatch also uses Selenium standalone server for deploying the test cases.
Besides it also aims at the simplification of integrating the test cases with BrowserStack to execute your test cases on the cloud.

#The basic workflow of Nightwatch The basic workflow of Nightwatch is as follows

  1. Nightwatch works by sending HTTP request to the selenium server with the right parameters and also
    interpreting the response.
  2. Nightwatch needs to send atleast two requests to the selenium server in order top perform a command or assertion.
    In the first request Selenium needs to locate the element, the CSS selector or the XPATH and in the second request it performs the required operation of the command or applying an assertion.

#Steps required to install nightwatch Steps required to install nightwatch in your system are as follows.

  1. First install npm in your system if you do not have npm already installed. Use the command
    sudo apt-get install npm (npm will by default install node in your system). npm is node package manager which will help the users to install any node package diretly from the node repository.
  2. To test whether npm is installed or not just type in the command npm -version. This will give you the latest
    npm version installed in your machine.
    P.S: npm will create a directory called node_modules in your home directory where it will keep all the packages
    installed in the system.
  3. To install nightwatch in your system just type in the command line npm -g install nightwatch.
    This will install nightwatch in your system. Please take care to put the -g. Otherwise the nightwatch command
    will not be available globally. You will have to manually mention the path of the nightwatch bin file
    in the .bashrc
  4. To check whether nightwatch is installed or not just type in the command nightwatch -version

#Setting up the architecture of the automation project

  1. Create a folder name NightwatchAutomation for your automation project.
  2. Now goto the project directory
  3. Create a bin directory which will consist of the project binaries such as the gecko driver, chrome driver and phantomjs driver.
  4. Create a lib directory which will have the selenium stand alone server.
  5. Create a reports directory which will have the xml reports generated after every test run.
  6. Create a screenshots directory which will have the screenshots for each step executed.
  7. Create a tests directory which will consist of the automated tests written.
  8. Create a nightwatch.json configuration file which will consist of the configurational parameters for executing a test run.

P.S: Follow on the configuration changes I have made in the nightwatch.json file.

#How to run your test cases using Nightwatch The following test cases or test suites can be executed using Nightwatch using the following command nightwatch --test tests/demotest.js where demotest.js is the required js file.

#Test Reports Generated By default the test reports generated by Nightwatch are in XML format. Now if you want your reports to be generated in html format install the library nightwatch-html-reporter using the command npm install -g nightwatch-html-reporter. Now all you need to do is run the command nightwatch-html-reporter -d <ReportDirectoryPath> and this library will generate you the html report for the corresponding xml report in your nightwatch report directory. For further information on nightwatch-html-reporter follow the link
https://github.com/jls/nightwatch-html-reporter

#Notaries

  1. The command to shut selenium server from URL is http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer. This command will actually help you shut down selenium server from the server itself rather than stopping it from the terminal. This URL is actually very handy when working on Nightwatch.
  2. It's essential that you go through the SeleniumDebug.log that would help you debug any discrepancies that the server is encountering when executing the selenese scripts.

About

Contains the codebase for nightwatch automation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published