Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Nightwatch.js (vodQA Shots - Pune 2017)

This session was taken at vodQA Shots held in Pune.

Details include :
- quick understanding of Nightwatch.js
- writing tests with PageObject model using nightwatch
- how to run tests against specific browsers/environments in parallel

  • Login to see the comments

  • Be the first to like this

Nightwatch.js (vodQA Shots - Pune 2017)

  1. 1. Join The Night’s Watch Nightwatch.js : an automated testing framework for web applications and websites, written in Node.js
  2. 2. About Me @Smriti_Tuteja https://www.linkedin.com/in/smritituteja/ https://github.com/SmritiTuteja http://smritituteja.in/
  3. 3. Why Nightwatch? ● Quick setup and easy to write ● Uses css or xpath as selectors ● Built-in support for POM ● Built-in test runner ● Saucelabs + browserstack support ● Custom commands + custom assertions possible ● Can also be used to write Node.js Unit tests 3
  4. 4. Stats 4 Latest version v0.9.16 Releases 127 Contributors 59 Downloads/month ~3,00,000 Open Issues 219
  5. 5. Requirements ● Node.js ● Java JDK >= 7 ● Selenium download: ○ Selenium-server-standalone ○ Chromedriver ● Nightwatch via npm ● Firefox: ○ Selenium 2.x && firefox < v48: firefoxdriver ○ Selenium 3.x | | firefox >= v48 : geckodriver 5
  6. 6. How It Works? 6 Source: http://nightwatchjs.org/
  7. 7. Command Queue Execution
  8. 8. Command Queue Execution..
  9. 9. Command Queue Execution..
  10. 10. Command Queue Execution..
  11. 11. Page Objects API
  12. 12. Page Objects API..
  13. 13. Page Object Command API Methods
  14. 14. Assertions and Expectations ● Expect: ○ Based on Chai Expect assertion library ● Assert: ○ assert/verify library
  15. 15. CSS Selectors - tips and tricks ● Class name ends with: ○ a[href$="/wordpress.com/"] ● Class name starts with: ○ a[href^="/wordpress.com/"] ● Class name contains: ○ a[href*="/wordpress.com/"] ● Child: ○ Direct child: div > a ○ child/subchild: div a ● Next adjacent element of same parent: ○ input.username + input (choses input field after username) ● Third li element in list: ○ ul#list li:nth-of-type(3)
  16. 16. Command Line Options ● --config ● --env ● --test ● --test --testcase ● --group ● --tag ● --skiptags
  17. 17. ES6 with NightWatch ● Create a .babelrc config file: { "presets": [ "es2015" ], "plugins": [ "add-module-exports" ] } ● Add following to nightwatch config: require('babel-core/register'); module.exports = require('./nightwatch.json');
  18. 18. THANK YOU Q & A Git Repo: https://github.com/SmritiTuteja/vodQA_Shots_NightWatch

×