Know Your Test Automation Tools : Test Automation with NightwatchJS

Know Your Test Automation Tools : Test Automation with NightwatchJS

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         
No alt text provided for this image


Cristian Mira

Software Test Automation Engineer

2 年

Thanks for sharing

回复

要查看或添加评论,请登录

Kushan Shalindra Amarasiri的更多文章

社区洞察

其他会员也浏览了