SlideShare a Scribd company logo
Night watch
…with QA
Carsten Sandtner (@casarock)
mediaman// Gesellschaft für Kommunikation mbH
about:me
Carsten Sandtner
@casarock
Head of Software Development
//mediaman GmbH
Night Watch with QA
Testing
Unit Tests
Integration Tests
System Tests
NationalMuseumofAmericanHistorySmithsonianInstitution-https://flic.kr/p/e6s1Lr
User
Acceptance Tests
BrettJordan-https://flic.kr/p/7ZRSzA
UAT
System Test
Integration Test
Unit Test
Preliminary design
Detailed design
Implementation
Requirements
UAT
Integration Test
Unit Test
Detailed design
Implementation
Requirements
System TestPreliminary design
by7263255-https://flic.kr/p/6YgDNN
Night Watch with QA
Night Watch with QA
Testing pyramid
# of Tests
easytoautomate
Implementation Unit Test
TDD
Integration Test
Unit Test
Detailed design
Implementation Unit Test
System Test
Integration Test
Unit Test
Preliminary design
Detailed design
Implementation
Automated
E2E Test
Night Watch with QA
Night Watch with QA
Night Watch with QA
– http://nightwatchjs.org/
„Nightwatch.js is an easy to use Node.js based End-
to-End (E2E) testing solution for browser based apps
and websites. It uses the powerful Selenium
WebDriver API to perform commands and assertions
on DOM elements.“
Nightwatch & WebDriver
Features
• Clean syntax
• Build-in test runner
• support for CSS and Xpath Selectors
• Grouping and filtering of Tests
• Saucelab and Browserstack support
• Extendable (Custom Commands)
• CI support!
Installation
$ npm install [-g] nightwatch
… and Download Selenium-Server-Standalone!
Done.
Nightwatch project
structure
├──bin/
| ├──chromedriver
| └──seleniumdriver.jar
|
├──data/
| └──globals.js
|
├──reports/
| └──fancyreports.xml
|
├──tests/
| ├──meaningfultest1.js
| ├──meaningfultest2.js
| └── …
└──nightwatch.js[on]
Nightwatch.js
module.exports = {
"src_folders": ["tests"],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "./objects/",
"globals_path": "",
"selenium": {
"start_process": true,
"server_path": "bin/selenium-server-standalone-2.53.1.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./bin/chromedriver",
"webdriver.ie.driver": "",
"webdriver.gecko.driver" : "./bin/geckodriver090"
}
},
Nightwatch.js - Test setup.
"test_settings": {
"default": {
"launch_url": "http://localhost",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "chrome",
"marionette": true
}
},
“staging“: {
. . .
},
Nightwatch.js - Browser
setup
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
};
Simple Nightwatch test
module.exports = {
'Google Webtechcon' : function (client) {
client
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.assert.title('Google')
.assert.visible('input[type=text]')
.setValue('input[type=text]', 'webtechcon')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.pause(1000)
.assert.containsText('#rso > div.g > div > div > h3 > a',
'WebTech Conference 2016')
.end();
}
};
Test execution
$ nightwatch [-c nightwatch.js] tests/simplegoogle.js
Night Watch with QA
Tests in detail
Arrange and assert
module.exports = {
'Google Webtechcon' : function (client) {
client
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.assert.title('Google')
.assert.visible('input[type=text]')
.end();
}
};
arrange
assert
Arrange, action and assert
module.exports = {
'Google Webtechcon' : function (client) {
client
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.assert.title('Google')
.assert.visible('input[type=text]')
.setValue('input[type=text]', 'webtechcon')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.pause(1000)
.assert.containsText('#rso > div.g > div > div > h3 > a',
'WebTech Conference 2016')
.end();
}
arrange
assert
assert
action
Hardcoded values?
Hardcoded values
module.exports = {
'Google Webtechcon' : function (client) {
client
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.assert.title('Google')
.assert.visible('input[type=text]')
.end();
}
};
Using globals
module.exports = {
'Google Webtechcon' : function (client) {
var globals = client.globals;
client
.url(globals.url)
.waitForElementVisible('body', 1000)
.assert.title(globals.static.pageTitle)
.assert.visible(globals.selectors.searchField)
.end();
}
};
Define globals
module.exports = {
url: 'http://www.google.com',
selectors: {
'searchField': 'input[type=text]'
},
static: {
'pageTitle': 'Google'
}
}
Save as data/google.js
Add to config (test-settings)
module.exports = {
. . .
"test_settings": {
"default": {
"launch_url": "http://localhost",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "chrome",
"marionette": true
},
"globals": require('./data/google')
},
. . .
Night Watch with QA
Use Page Objects!
Using Page Objects
module.exports = {
'url': 'http://www.google.com',
'elements': {
'searchField': 'input[type=text]'
}
};
Save as object/google.js
Add objects to config
module.exports = {
"src_folders": ["tests"],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "./objects/",
"globals_path": "",
"selenium": {. . .},
"test_settings": {. . .}
};
Add objects to config
module.exports = {
'Google Webtechcon' : function (client) {
var googlePage = client.page.google(),
globals = client.globals;
googlePage.navigate()
.waitForElementVisible('body', 1000)
.assert.title(globals.static.pageTitle)
.assert.visible('@searchField')
.end();
}
};
More PageObjects
awesomeness
module.exports = {
'url': 'http://www.some.url',
'elements': {
'passwordField': 'input[type=text]',
'usernameField': 'input[type=password]',
'submit': 'input[type=submit]'
},
commands: [{
signInAsAdmin: function() {
return this.setValue('@usernameField', 'admin')
.setValue('@passwordField', 'password')
.click('@submit');
}
}]
};
In your test
module.exports = {
'Admin log in' : function (browser) {
var login = browser.page.admin.login();
login.navigate()
.signInAsAdmin();
browser.end();
}
};
Grouping tests
$ nightwatch --group smoketests
$ nightwatch --skipgroup smoketests
$ nightwatch --skipgroup login,whatever
Test groups
|
├──tests/
| ├──smoketests/
| | ├──meaningfulTest1.js
| | ├──meaningfulTest2.js
| | └── ……
| └──login/
| ├──authAndLogin.js
| └── ……
Tag your tests
$ nightwatch --tag login
$ nightwatch --tag login --tag something_else
$ nightwatch --skiptags login
$ nightwatch --skiptags login,something_else
In your test
module.exports = {
'@tags': ['login', 'sanity'],
'Admin log in' : function (browser) {
var login = browser.page.admin.login();
login.navigate()
.signInAsAdmin();
browser.end();
}
};
Demo
Nightwatch is extendable!
• Write custom commands
• add custom assertions
• write custom reporter
Nightwatch is Javascript!
• Using Filereaders
• CSV, Excel etc.
• write helpers if needed!
Night Watch with QA
Nightwatch
@Mediaman
The problem
Before Nightwatch
The solution
UAT
System Test
Integration Test
Unit Test
Preliminary design
Detailed design
Implementation
Requirements
✓ ✓
✓ ✓
✓ ✓
Thanks!
Carsten Sandtner
@casarock
sandtner@mediaman.de
https://github.com/casarock
(◡‿◡✿)

More Related Content

ZIP
Automated Frontend Testing
PDF
Testing nightwatch, by David Torroija
PPTX
Browser Automated Testing Frameworks - Nightwatch.js
PDF
Testing Web Applications
PDF
20160905 - BrisJS - nightwatch testing
PDF
Join the darkside: Selenium testing with Nightwatch.js
PDF
Front-End Testing: Demystified
PDF
Nightwatch at Tilt
Automated Frontend Testing
Testing nightwatch, by David Torroija
Browser Automated Testing Frameworks - Nightwatch.js
Testing Web Applications
20160905 - BrisJS - nightwatch testing
Join the darkside: Selenium testing with Nightwatch.js
Front-End Testing: Demystified
Nightwatch at Tilt

What's hot (20)

PDF
Node.js and Selenium Webdriver, a journey from the Java side
PDF
Fullstack End-to-end test automation with Node.js, one year later
PDF
High Performance JavaScript 2011
PPTX
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
PDF
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
PDF
Front-end Automated Testing
PPTX
Protractor Tutorial Quality in Agile 2015
KEY
Agile JavaScript Testing
PDF
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
PPT
Testing in AngularJS
PDF
Real World Selenium Testing
PDF
jQuery Proven Performance Tips & Tricks
PPTX
Automated Smoke Tests with Protractor
PDF
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
PDF
UI Testing Best Practices - An Expected Journey
PDF
Automated Testing in Angular Slides
PDF
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
PDF
Getting By Without "QA"
PDF
Automation Abstraction Layers: Page Objects and Beyond
PDF
Test automation & Seleniun by oren rubin
Node.js and Selenium Webdriver, a journey from the Java side
Fullstack End-to-end test automation with Node.js, one year later
High Performance JavaScript 2011
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
Front-end Automated Testing
Protractor Tutorial Quality in Agile 2015
Agile JavaScript Testing
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Testing in AngularJS
Real World Selenium Testing
jQuery Proven Performance Tips & Tricks
Automated Smoke Tests with Protractor
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
UI Testing Best Practices - An Expected Journey
Automated Testing in Angular Slides
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Getting By Without "QA"
Automation Abstraction Layers: Page Objects and Beyond
Test automation & Seleniun by oren rubin
Ad

Viewers also liked (7)

PDF
Building testable chrome extensions
PDF
SketchApp Meetup Frankfurt - #1st Round
PDF
WebVR - JAX 2016
PPTX
Python in the Hadoop Ecosystem (Rock Health presentation)
DOCX
Sreekanth java developer raj
PDF
Node Foundation Membership Overview 20160907
PDF
Resume - Taranjeet Singh - 3.5 years - Java/J2EE/GWT
Building testable chrome extensions
SketchApp Meetup Frankfurt - #1st Round
WebVR - JAX 2016
Python in the Hadoop Ecosystem (Rock Health presentation)
Sreekanth java developer raj
Node Foundation Membership Overview 20160907
Resume - Taranjeet Singh - 3.5 years - Java/J2EE/GWT
Ad

Similar to Night Watch with QA (20)

PPTX
Google app engine by example
PPTX
Protractor framework architecture with example
PDF
Vaadin & Web Components
PDF
Serverless Angular, Material, Firebase and Google Cloud applications
PPTX
Jan 2017 - a web of applications (angular 2)
PDF
Building and deploying React applications
PPTX
Azure from scratch part 4
PPTX
Use Eclipse technologies to build a modern embedded IDE
PDF
Front End Development for Back End Java Developers - Jfokus 2020
PDF
Front End Development for Back End Developers - vJUG24 2017
PPT
Test strategy for web development
PPTX
Open Admin
PDF
How to Webpack your Django!
PPTX
CiklumJavaSat15112011:Andrew Mormysh-GWT features overview
PDF
Vaadin 7 CN
PPTX
Magic of web components
PPT
Google Web Toolkits
PDF
Testing web application with Python
PPTX
What's new in android jakarta gdg (2015-08-26)
PDF
From Web App Model Design to Production with Wakanda
Google app engine by example
Protractor framework architecture with example
Vaadin & Web Components
Serverless Angular, Material, Firebase and Google Cloud applications
Jan 2017 - a web of applications (angular 2)
Building and deploying React applications
Azure from scratch part 4
Use Eclipse technologies to build a modern embedded IDE
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Developers - vJUG24 2017
Test strategy for web development
Open Admin
How to Webpack your Django!
CiklumJavaSat15112011:Andrew Mormysh-GWT features overview
Vaadin 7 CN
Magic of web components
Google Web Toolkits
Testing web application with Python
What's new in android jakarta gdg (2015-08-26)
From Web App Model Design to Production with Wakanda

More from Carsten Sandtner (15)

PDF
State of Web APIs 2017
PDF
Headless in the CMS
PDF
Always on! Or not?
PDF
Always on! ... or not?
PDF
WebVR - MobileTechCon Berlin 2016
PDF
Evolution der Web Entwicklung
PDF
HTML5 Games for Web & Mobile
PDF
What is responsive - and do I need it?
PDF
Web apis JAX 2015 - Mainz
PDF
Web APIs - Mobiletech Conference 2015
PDF
Web APIs – expand what the Web can do
PDF
Firefox OS - A (mobile) Web Developers dream - DWX14
PDF
Firefox OS - A (web) developers dream - muxCamp 2014
PDF
Mozilla Brick - Frontend Rhein-Main June 2014
PDF
Traceur - Javascript.next - Now! RheinmainJS April 14th
State of Web APIs 2017
Headless in the CMS
Always on! Or not?
Always on! ... or not?
WebVR - MobileTechCon Berlin 2016
Evolution der Web Entwicklung
HTML5 Games for Web & Mobile
What is responsive - and do I need it?
Web apis JAX 2015 - Mainz
Web APIs - Mobiletech Conference 2015
Web APIs – expand what the Web can do
Firefox OS - A (mobile) Web Developers dream - DWX14
Firefox OS - A (web) developers dream - muxCamp 2014
Mozilla Brick - Frontend Rhein-Main June 2014
Traceur - Javascript.next - Now! RheinmainJS April 14th

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
KodekX | Application Modernization Development
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Modernizing your data center with Dell and AMD
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPT
Teaching material agriculture food technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KodekX | Application Modernization Development
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Review of recent advances in non-invasive hemoglobin estimation
Network Security Unit 5.pdf for BCA BBA.
Building Integrated photovoltaic BIPV_UPV.pdf
NewMind AI Monthly Chronicles - July 2025
Modernizing your data center with Dell and AMD
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Chapter 3 Spatial Domain Image Processing.pdf
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Teaching material agriculture food technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Advanced methodologies resolving dimensionality complications for autism neur...
The Rise and Fall of 3GPP – Time for a Sabbatical?

Night Watch with QA