NightWatchTest
Test automation framework for End to End UI Test testing using NodeJS
, Nightwatch
, Typescript
,
Selenium
for testing locally and Sauce Labs
.
##Prerequisites
To proceed you need a Mac, Windows, or Linux machine, and:
-
node
installed. (4.* LTS release) -
npm
installed (usually installed along withnode
). After installing nodejs, the version shipped by nodejs for 4.* LTS release is very old and needs to be upgraded to the latest version (3.*). To install npmnpm install npm -g
-
If tests are to be executed on Sauce Labs, Sauce labs Username and API Key for the user
-
Copy of this repository using Git or from a browser
git clone https://github.com/rkavalap/NightWatchTest or https://github.com/rkavalap/NightWatchTest/archive/master.zip
-
From the copy of the source i.e NightWatchTest directory
npm install
Install's all the dependent packages for this project under node_modules folder.
##To clean & compile source:
npm run build
##To Execute Test:
To execute individual test suite (single file of test cases) use the "-t" argument and path of the test case under build output folder and "--env" argument.
node node_modules/nightwatch/bin/runner.js -t buildOutput/javascript1.js --env devtest-chrome-win8
To execute multiple test cases you can use --tag argument to nightwatch. Each test suite needs to have tag attribute defined.
##Configs
There are two kinds of environment/configs in this project:
- The default config is defined in
defaults.json5
, which all other configs inherit from. - Dynamically configurations are generated by combining each of the top-level objects in
capabilities.json5
anddeployments.json5
.
###Config Merging
When nightwatch
starts, it's passed configuration that is gathered or generated by nightwatch.conf.js
. The generation does these things:
- Loads
defaults.json5
, which contains the base configuration. - Generates what
nightwatch
refers to as an "environment" (a configuration object withintest_settings
), for each combination of objects incapabilities.json5
anddeployments.json5
. The generated environments are likedevtest-chrome-win8
.- deployments are things like
devtest
orCI
. Configs here are available to all generated environments with the same deployment (i.e.devtest-chrome-win8
but notci-chrome-win8
). - capabilities are selenium settings (i.e. the
-chrome-win8
part). Configs here are available to all generated environments with the same capability (i.e.devtest-chrome-win8
andci-chrome-win8
, but notdevtest-ie10-win7
).
- deployments are things like
- Loads any settings in
configs/
, and applies them also as environments undertest_settings
.
##Project source Layout:
tests
- Contains all the UI test scripts.globalsmodule.js
- Nightwatch globals module filegulpfile.js
- Build file (compilation from ts to js using Gulp)nightwatch.conf.js
- config file for nightwatchpackage.json
- dependent nodejs packages used for this project installed under node_modules directorytypings
- Created on execution of build. Provides intellisense support for Nightwatch framework.
##Intellisense
Experience should be similar to Visual studio and other IDE's supporting Typescript Intellisense.
##References
Nightwatch Guide
Nightwatch Wiki
Page Object
article by Martin FowlerSelenium PageObjects wiki
Selenium DesiredCapabilities