Know Your Test Automation Tools : Test Automation with NightwatchJS
Kushan Shalindra Amarasiri
Head of Quality Engineering at Social Catfish
Nightwatch JS is a WebDriver protocol based test automation tool in JavaScript language and its an end to end test automation tool, like WebDriverIO.
So let's start to learn about NightwatchJS and first of all we need to install the following components as pre-requisites.
npm install -g nightwatch //Install NightwatchJS
npm install chromedriver --save-dev //Install Chromedriver
Then create a folder called NightwatchJS and create a subfolder named test.
Add the following script which automates Guru99 demo site login.
module.exports?=?{
????'Guru?99?Login'?:?function(browser)?{
??????browser
????????.url('https://demo.guru99.com/v4/')
????????.setValue('input[name=uid]',?"mngr332873")
????????.setValue('input[name=password]',?"umEtyvy")
????????.click('input[name=btnLogin]')
????????.assert.containsText('tr.heading3?>?td',?'Manger?Id?:?mngr332873')
????????.end()
????}
??};
To run the script, run with the following command
nightwatch .\test\test1.js //will run in Firefox
nightwatch .\test\test1.js -e chrome // will run in Chrome
Software Test Automation Engineer
2 年Thanks for sharing