SlideShare a Scribd company logo
JS Test Automation Workshop 
Introducing NightwatchJS & DalekJS 
Alexei Vinogradov 
Kahlil Lechelt
Alexei Vinogradov 
freiberuflicher IT-Berater 
Test, Testmanagement, Testautomatisierung, 
Coaching 
email: alexei@vinogradov-it.de 
skype: alexejv 
twitter: @i_vino 
https://www.softwerkskammer.org/groups/testing
Goals of the workshop 
• Learn rapid tests development from scratch 
• NightwatchJS & DalekJS: compare for same tasks 
• real-world examples: ING-DiBa Bank
CSS Selectors 
from CSS Cheat Sheet https://www.addedbytes.com/
XPath 
Expression Description 
nodename Selects all nodes with the name "nodename" 
/ Selects from the root node 
// Selects nodes in the document from the current node that match the selection no matter 
where they are 
. Selects the current node 
.. Selects the parent of the current node 
@ Selects attributes 
Path Expression Result 
bookstore Selects all nodes with the name "bookstore" 
/bookstore Selects the root element bookstore Note: If the path starts with a slash ( / ) it always 
represents an absolute path to an element! 
bookstore/book Selects all book elements that are children of bookstore 
//book Selects all book elements no matter where they are in the document 
bookstore//book Selects all book elements that are descendant of the bookstore element, no matter where 
they are under the bookstore element 
//@lang Selects all attributes that are named lang 
from XPath Tutorial http://www.w3schools.com/XPath/
XPath 
Path Expression Result 
/bookstore/book[1] Selects the first book element that is the child of the bookstore element. 
Note: In IE 5,6,7,8,9 first node is[0], but according to W3C, it is [1]. To 
solve this problem in IE, set the SelectionLanguage to XPath: In 
/bookstore/book[last()] Selects the last book element that is the child of the bookstore element 
/bookstore/book[last()-1] Selects the last but one book element that is the child of the bookstore 
from XPath Tutorial http://www.w3schools.com/XPath/ 
element 
/bookstore/book[position()<3] Selects the first two book elements that are children of the bookstore 
element 
//title[@lang] Selects all the title elements that have an attribute named lang 
//title[@lang='en'] Selects all the title elements that have an attribute named lang with a 
value of 'en' 
/bookstore/book[price>35.00] Selects all the book elements of the bookstore element that have a price 
element with a value greater than 35.00 
/bookstore/book[price>35.00]/title Selects all the title elements of the book elements of the bookstore 
element that have a price element with a value greater than 35.00
XPath 
from XPath Tutorial http://www.w3schools.com/XPath/ 
Wildcard Description 
* Matches any element node 
@* Matches any attribute node 
node() Matches any node of any kind 
Path Expression Result 
/bookstore/* Selects all the child nodes of the bookstore element 
//* Selects all elements in the document 
//title[@*] Selects all title elements which have any attribute 
Path Expression Result 
//book/title | //book/price Selects all the title AND price elements of all book elements 
//title | //price Selects all the title AND price elements in the document 
/bookstore/book/title | //price Selects all the title elements of the book element of the bookstore 
element AND all the price elements in the document
Tools & Debugging 
• SelectorGadget (Chrome extension) 
• $$(„<css selector>“) in Web Developer Console 
• $x(„<xpath expr>“) in Web Developer Console
NightwatchJS: setup 
• Download & install node.js (incl. npm) 
• npm install -g nightwatch 
• download selenium-server-standalone-2.x.y.jar 
• create nightwatch.json 
• create tests, logs, reports,screenshots folders 
• install Firefox or Chrome
NightwatchJS: setup 
nightwatch.json
Hello World
Example: Fails 
.assert - when an assertion fails, the test ends, skipping all other 
assertions. 
.verify - when an assertion fails, the test logs the failure and 
continues with other assertions. 
optional msg 
Fail 
Error 
Fail 
Skipped
Example: Fails
Optimization tips 
• learn configuration and running command line options 
from http://nightwatchjs.org/guide 
• start selenium with „java -jar selenium-server-standalone- 
2.x.y.jar“ and set selenium "start_process" 
to false in nightwatch.json 
• run only selected tests with options --test (-t), --group 
(-g), --skipgroup (-s), --filter(-f)! 
• run different environments in parallel: nightwatch -e 
default,chrome
Nightwatch API 
• Reference at http://nightwatchjs.org/api 
Assertions 
attributeEquals 
containsText 
cssClassPresent 
cssClassNotPresent 
cssProperty 
elementPresent 
elementNotPresent 
hidden 
title 
urlContains 
urlEquals 
value 
valueContains 
visible 
Commands (…excerpt…) 
click 
deleteCookie 
end 
getAttribute 
getCookie 
getText 
getTitle 
getValue 
moveToElement 
pause 
resizeWindow 
saveScreenshot 
setValue 
submitForm 
switchWindow 
waitForElementVisible 
Protocol (…excerpt…) 
doubleClick 
element 
execute 
frame 
keys 
mouseButtonDown 
mouseButtonUp 
moveTo 
refresh 
session 
status 
timeouts 
title 
url 
windowSize
Case 1 
• Check the Logo and „Start“-Link 
• run as a new group -g (create new folder in 
tests) 
• do screenshot
Case 2 
• Click to „Kontakte“ and check if the 3rd tab is 
„Anschrift“ 
• run as a single test -t 
• use XPath and CSS-Selector 
• do some proper logging (optional params)
The End. 
Questions? 
skype: alexejv 
email: alexei@vinogradov-it.de 
twitter: @i_vino

More Related Content

PDF
Introduction to Protractor
KEY
Agile JavaScript Testing
PDF
Intro to testing Javascript with jasmine
PDF
Night Watch with QA
PPTX
Protractor Tutorial Quality in Agile 2015
PPTX
Testing frontends with nightwatch & saucelabs
PDF
Unit Testing JavaScript Applications
PDF
Introduction to Selenium and Ruby
Introduction to Protractor
Agile JavaScript Testing
Intro to testing Javascript with jasmine
Night Watch with QA
Protractor Tutorial Quality in Agile 2015
Testing frontends with nightwatch & saucelabs
Unit Testing JavaScript Applications
Introduction to Selenium and Ruby

What's hot (20)

PDF
Painless JavaScript Testing with Jest
PPT
Testing in AngularJS
PPTX
Code ceptioninstallation
PDF
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
PPTX
Testing Ext JS and Sencha Touch
PDF
Unit testing JavaScript using Mocha and Node
PDF
Angularjs - Unit testing introduction
PDF
Vuejs testing
PDF
Testing Django Applications
PDF
CasperJs Enjoy Functional Testing
DOC
Selenium Automation Using Ruby
PPTX
Angular UI Testing with Protractor
PDF
Automated Testing with Ruby
PDF
Superfast Automated Web Testing with CasperJS & PhantomJS
PPTX
Protractor framework – how to make stable e2e tests for Angular applications
PPTX
Jasmine with JS-Test-Driver
PDF
Intro To JavaScript Unit Testing - Ran Mizrahi
PDF
Сергей Больщиков "Protractor Tips & Tricks"
PDF
CasperJS and PhantomJS for Automated Testing
PPT
Automated Testing With Watir
Painless JavaScript Testing with Jest
Testing in AngularJS
Code ceptioninstallation
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
Testing Ext JS and Sencha Touch
Unit testing JavaScript using Mocha and Node
Angularjs - Unit testing introduction
Vuejs testing
Testing Django Applications
CasperJs Enjoy Functional Testing
Selenium Automation Using Ruby
Angular UI Testing with Protractor
Automated Testing with Ruby
Superfast Automated Web Testing with CasperJS & PhantomJS
Protractor framework – how to make stable e2e tests for Angular applications
Jasmine with JS-Test-Driver
Intro To JavaScript Unit Testing - Ran Mizrahi
Сергей Больщиков "Protractor Tips & Tricks"
CasperJS and PhantomJS for Automated Testing
Automated Testing With Watir
Ad

Viewers also liked (16)

PDF
Join the darkside: Selenium testing with Nightwatch.js
PPTX
Browser Automated Testing Frameworks - Nightwatch.js
PPTX
PDF
VISUAL CHEAT SHEET
PPTX
Severity и Priority для неначинающих: очевидное и невероятное
PDF
Testing nightwatch, by David Torroija
PDF
20160905 - BrisJS - nightwatch testing
PPTX
Automated Testing using JavaScript
PPTX
Tooling for the productive front-end developer
PDF
Front-End Testing: Demystified
PDF
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
PDF
5-Whys Method
PPT
Selenium
PPTX
Selenium web driver
PPTX
Silk Performer Presentation v1
PDF
Automated Web Testing using JavaScript
Join the darkside: Selenium testing with Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
VISUAL CHEAT SHEET
Severity и Priority для неначинающих: очевидное и невероятное
Testing nightwatch, by David Torroija
20160905 - BrisJS - nightwatch testing
Automated Testing using JavaScript
Tooling for the productive front-end developer
Front-End Testing: Demystified
從改寫後台 jQuery 開始的 Vue.js 宣告式渲染
5-Whys Method
Selenium
Selenium web driver
Silk Performer Presentation v1
Automated Web Testing using JavaScript
Ad

Similar to Javascript Test Automation Workshop (21.08.2014) (20)

PDF
Deep Dive Into NightWatch- Workshop by Pallavi Sharma.pdf
PPTX
Automated_Testing_Selenium
PDF
Real World Selenium
PPTX
Automatedtestingwithselenium shubham jain
PDF
Nightwatch.js (vodQA Shots - Pune 2017)
PPTX
X path
PPTX
X path
PPTX
Automation Testing by Selenium Web Driver
PDF
Real World Selenium Testing
PPTX
Nightwatch 101 - Salvador Molina
PDF
Browser testing with nightwatch.js - Drupal Europe
PPTX
Browser testing with nightwatch.js
PPTX
TApp Documentation
PDF
Drupal + selenium
PDF
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
PDF
How To Use Selenium Successfully (Java Edition)
PPTX
Automated testing with selenium prasad bapatla
PPTX
Web based automation testing on Node.js environment
PDF
PPTX
Selenium
Deep Dive Into NightWatch- Workshop by Pallavi Sharma.pdf
Automated_Testing_Selenium
Real World Selenium
Automatedtestingwithselenium shubham jain
Nightwatch.js (vodQA Shots - Pune 2017)
X path
X path
Automation Testing by Selenium Web Driver
Real World Selenium Testing
Nightwatch 101 - Salvador Molina
Browser testing with nightwatch.js - Drupal Europe
Browser testing with nightwatch.js
TApp Documentation
Drupal + selenium
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
How To Use Selenium Successfully (Java Edition)
Automated testing with selenium prasad bapatla
Web based automation testing on Node.js environment
Selenium

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
KodekX | Application Modernization Development
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
cuic standard and advanced reporting.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
Electronic commerce courselecture one. Pdf
A Presentation on Artificial Intelligence
Machine learning based COVID-19 study performance prediction
Understanding_Digital_Forensics_Presentation.pptx
KodekX | Application Modernization Development
Advanced methodologies resolving dimensionality complications for autism neur...
cuic standard and advanced reporting.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
NewMind AI Monthly Chronicles - July 2025
Encapsulation_ Review paper, used for researhc scholars
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing
The Rise and Fall of 3GPP – Time for a Sabbatical?
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25 Week I

Javascript Test Automation Workshop (21.08.2014)

  • 1. JS Test Automation Workshop Introducing NightwatchJS & DalekJS Alexei Vinogradov Kahlil Lechelt
  • 2. Alexei Vinogradov freiberuflicher IT-Berater Test, Testmanagement, Testautomatisierung, Coaching email: alexei@vinogradov-it.de skype: alexejv twitter: @i_vino https://www.softwerkskammer.org/groups/testing
  • 3. Goals of the workshop • Learn rapid tests development from scratch • NightwatchJS & DalekJS: compare for same tasks • real-world examples: ING-DiBa Bank
  • 4. CSS Selectors from CSS Cheat Sheet https://www.addedbytes.com/
  • 5. XPath Expression Description nodename Selects all nodes with the name "nodename" / Selects from the root node // Selects nodes in the document from the current node that match the selection no matter where they are . Selects the current node .. Selects the parent of the current node @ Selects attributes Path Expression Result bookstore Selects all nodes with the name "bookstore" /bookstore Selects the root element bookstore Note: If the path starts with a slash ( / ) it always represents an absolute path to an element! bookstore/book Selects all book elements that are children of bookstore //book Selects all book elements no matter where they are in the document bookstore//book Selects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element //@lang Selects all attributes that are named lang from XPath Tutorial http://www.w3schools.com/XPath/
  • 6. XPath Path Expression Result /bookstore/book[1] Selects the first book element that is the child of the bookstore element. Note: In IE 5,6,7,8,9 first node is[0], but according to W3C, it is [1]. To solve this problem in IE, set the SelectionLanguage to XPath: In /bookstore/book[last()] Selects the last book element that is the child of the bookstore element /bookstore/book[last()-1] Selects the last but one book element that is the child of the bookstore from XPath Tutorial http://www.w3schools.com/XPath/ element /bookstore/book[position()<3] Selects the first two book elements that are children of the bookstore element //title[@lang] Selects all the title elements that have an attribute named lang //title[@lang='en'] Selects all the title elements that have an attribute named lang with a value of 'en' /bookstore/book[price>35.00] Selects all the book elements of the bookstore element that have a price element with a value greater than 35.00 /bookstore/book[price>35.00]/title Selects all the title elements of the book elements of the bookstore element that have a price element with a value greater than 35.00
  • 7. XPath from XPath Tutorial http://www.w3schools.com/XPath/ Wildcard Description * Matches any element node @* Matches any attribute node node() Matches any node of any kind Path Expression Result /bookstore/* Selects all the child nodes of the bookstore element //* Selects all elements in the document //title[@*] Selects all title elements which have any attribute Path Expression Result //book/title | //book/price Selects all the title AND price elements of all book elements //title | //price Selects all the title AND price elements in the document /bookstore/book/title | //price Selects all the title elements of the book element of the bookstore element AND all the price elements in the document
  • 8. Tools & Debugging • SelectorGadget (Chrome extension) • $$(„<css selector>“) in Web Developer Console • $x(„<xpath expr>“) in Web Developer Console
  • 9. NightwatchJS: setup • Download & install node.js (incl. npm) • npm install -g nightwatch • download selenium-server-standalone-2.x.y.jar • create nightwatch.json • create tests, logs, reports,screenshots folders • install Firefox or Chrome
  • 12. Example: Fails .assert - when an assertion fails, the test ends, skipping all other assertions. .verify - when an assertion fails, the test logs the failure and continues with other assertions. optional msg Fail Error Fail Skipped
  • 14. Optimization tips • learn configuration and running command line options from http://nightwatchjs.org/guide • start selenium with „java -jar selenium-server-standalone- 2.x.y.jar“ and set selenium "start_process" to false in nightwatch.json • run only selected tests with options --test (-t), --group (-g), --skipgroup (-s), --filter(-f)! • run different environments in parallel: nightwatch -e default,chrome
  • 15. Nightwatch API • Reference at http://nightwatchjs.org/api Assertions attributeEquals containsText cssClassPresent cssClassNotPresent cssProperty elementPresent elementNotPresent hidden title urlContains urlEquals value valueContains visible Commands (…excerpt…) click deleteCookie end getAttribute getCookie getText getTitle getValue moveToElement pause resizeWindow saveScreenshot setValue submitForm switchWindow waitForElementVisible Protocol (…excerpt…) doubleClick element execute frame keys mouseButtonDown mouseButtonUp moveTo refresh session status timeouts title url windowSize
  • 16. Case 1 • Check the Logo and „Start“-Link • run as a new group -g (create new folder in tests) • do screenshot
  • 17. Case 2 • Click to „Kontakte“ and check if the 3rd tab is „Anschrift“ • run as a single test -t • use XPath and CSS-Selector • do some proper logging (optional params)
  • 18. The End. Questions? skype: alexejv email: alexei@vinogradov-it.de twitter: @i_vino