SlideShare a Scribd company logo
End-to-end testing: from rookie to pro
Domenico Gemoli - @aberonni
Overview.
● What is end-to-end testing?
● Setup a test suite with WebdriverIO
● WebdriverIO under the hood
● Augment WebdriverIO with 3rd
party tools
● Advanced techniques for
end-to-end testing
What is
end-to-end testing?
End-to-end testing is a technique used to test
whether the flow of an application, from start to
finish, is behaving as expected
● Fail fast and catch bugs before going to
production
● Increase “Developer Confidence” - code
fearlessly and let the tests tell you if something is
broken
● Maintain quality without forcing people to do
numerous rounds of manual testing
1. Push to Git server
2. Build commit in CI server (Travis/Jenkins/TeamCity etc…)
3. Deploy built code to a testing/staging server
4. Run end-to-end test suite on that server
5. Report test status to monitoring tools
Build Deploy Test ReportPush
Ideal CI workflow
Why WebdriverIO?
Written in Javascript
with an easy API to
learn for those with
experience in unit
testing
Based on the
WebDriver protocol
which means solid
drivers and easy-ish
cross-browser testing
Active community that
continuously improves
the framework and
ships new features
Setup a test suite
with WebdriverIO
Learn the basics:
http://webdriver.io/guide.html
Deep dive into the API:
http://webdriver.io/api.html
Prerequisites.
● Basic JS knowledge
● Node
● Java (optional, only for cross-browser testing)
● At least one browser installed
$ mkdir webdriverio-example
$ cd webdriverio-example
$ npm init -y
$ npm install webdriverio --save-dev
$ npx wdio config
End to-end testing  from rookie to pro
const { assert } = require('chai');
describe('contact form', function() {
it('opens alert', function() {
// test script
});
});
// test script
browser.url('/');
$('input#email').setValue('charlie@gmail.com');
$('textarea#message').setValue('Hello World!');
$('input[type="submit"]').click();
assert.equal(
browser.alertText(),
`charlie@gmail.com says 'Hello World!'`
);
WebdriverIO
under the hood
End to-end testing  from rookie to pro
End to-end testing  from rookie to pro
End to-end testing  from rookie to pro
“This sounds like a lot of work. Isn’t
there an easy way to get this all
setup?”
Augment WebdriverIO
with 3rd party tools
3rd party tools
Use physical or
emulated mobile
devices to run your
tests
Manage your
selenium grid and
record videos of
your tests
Proprietary
solutions to offload
the work of setting
up Zalenium.
A flexible and scalable
container based
Selenium Grid with
video recording, live
preview, basic auth &
dashboard.
Docker and
kubernetes support
out of the box.
Cloud web and mobile
testing platform - test
across on-demand
browsers, operating
systems and real
mobile devices, without
installing or
maintaining virtual
machines, devices or
emulators
Appium is an
open-source tool for
automating native,
mobile web, and
hybrid applications on
iOS mobile, Android
mobile, and Windows
desktop platforms.
Advanced techniques
for end-to-end testing
VRT A11y Video Audio
Take screenshots
during tests and
implement visual
regression testing
Test web page for
a11y violations by
injecting Axe into
the page
Test whether a video
is playing or not, by
using the video’s
‘paused’ attribute
Test whether
audio is playing or
not, by injecting an
extension on the fly
Advanced techniques for testing trickier elements
VRT.
Take screenshots and
compare them with
baseline.
Easily catch visual
regressions and bugs
introduced by generic CSS
changes.
// array of diff results
// one result for each viewport size
const results = browser.checkElement('#footer');
const isExactSameImage = results.every(
result => result.isExactSameImage
);
assert.ok(isExactSameImage, 'footer has not
changed');
A11y testing with Axe.
Inject the axe-core library
into a web page.
Then use the axe-core
library to analyze the
website and detect a11y
violations.
const axeSource = require('axe-core').source;
browser.execute(axeSource);
const res = browser.executeAsync(function(done) {
axe.run(function(err, results) {
if (err) done(err);
done(results);
});
});
assert.lengthOf(res.value.violations, 0);
Video.
The easiest and most
reliable way to test video:
just check the ‘paused’
attribute.
Having tried various
techniques, this is the
simplest and has never
failed me
const isVideoPaused = browser.selectorExecute(
'#video',
// executes the following in the browser context
// videos is an array of elements corresponding
// to the given selector, just retrieve the
// `paused` state of the first video.
videos => videos[0].paused
);
assert.ok(!isVideoPaused, `video is playing`);
Audio.
Inject a chrome extension on
the fly. The extension will
leverage the chrome API to
inject a DOM element when
sound is playing on the
current tab.
Then simply check whether
the DOM element is present.
// snippet from extension
chrome.runtime.onMessage.addListener(request => {
if (request.audible) {
el.className = isPlayingAudioClass;
} else {
el.className = '';
}
});
// element injected by the extension
// if audio is playing
const isPlayingAudio =
browser.isExisting(isPlayingAudioClass);
assert(isPlayingAudio, 'audio is playing');
github.com/aberonni/webdriverio-demo-tests
You
“Shouldn’t we rather invest time in
unit and integration tests?.”
Me
“No”
The test pyramid myth
The testing pyramid tricks us into thinking that unit
tests are more important than end-to-end tests,
and that, if we have to choose, we should choose
unit tests.
The truth is that the testing pyramid is telling us
that we should prioritise unit tests. If forced to
choose, you should prefer to rely on end-to-end
tests because they are closest to the customer.
Me again
“Any test is better than no tests.”
workingatbooking.com
@aberonni
Thank you!

More Related Content

PDF
Automation Testing
PDF
Automated android testing using jenkins ci
PPTX
CI / CD w/ Codeception
PPTX
Genymotion with Jenkins
PPTX
Automated Infrastructure Testing
KEY
Jellyfish, JSCONF 2011
PDF
No more waiting for API - Android Stub Server
PDF
Instrumentación de entrega continua con Gitlab
Automation Testing
Automated android testing using jenkins ci
CI / CD w/ Codeception
Genymotion with Jenkins
Automated Infrastructure Testing
Jellyfish, JSCONF 2011
No more waiting for API - Android Stub Server
Instrumentación de entrega continua con Gitlab

What's hot (20)

PDF
Aikau testing tech talk live 83 20150204
PPTX
Introduction to Integration Testing With Cypress
PDF
Automated-Testing-inside-containers
PDF
Testing with Codeception (Webelement #30)
PPTX
Intro to JavaScript Tooling in Visual Studio Code
PPTX
Cypress Automation
PPTX
CI/CD for android
PDF
Testing PHP with Codeception
PDF
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
ODP
Building JBoss AS 7 for Fedora
PDF
Comment améliorer le quotidien des Développeurs PHP ?
PPTX
Automated Testing using JavaScript
PDF
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
PPT
Behat sauce
PPTX
Debugging in Node.js and Azure
PPTX
Automated Testing with Cucumber, PhantomJS and Selenium
PPTX
PhoneGap Day 2016 EU: Creating the Ideal Cordova Dev Environment
PDF
Testing Automaton - CFSummit 2016
PDF
Fastlane - Automation and Continuous Delivery for iOS Apps
PDF
探討Web ui自動化測試工具
Aikau testing tech talk live 83 20150204
Introduction to Integration Testing With Cypress
Automated-Testing-inside-containers
Testing with Codeception (Webelement #30)
Intro to JavaScript Tooling in Visual Studio Code
Cypress Automation
CI/CD for android
Testing PHP with Codeception
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Building JBoss AS 7 for Fedora
Comment améliorer le quotidien des Développeurs PHP ?
Automated Testing using JavaScript
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
Behat sauce
Debugging in Node.js and Azure
Automated Testing with Cucumber, PhantomJS and Selenium
PhoneGap Day 2016 EU: Creating the Ideal Cordova Dev Environment
Testing Automaton - CFSummit 2016
Fastlane - Automation and Continuous Delivery for iOS Apps
探討Web ui自動化測試工具
Ad

Similar to End to-end testing from rookie to pro (20)

PDF
Android UI Testing with Appium
ODP
RichFaces - Testing on Mobile Devices
PDF
Good practices for debugging Selenium and Appium tests
PPTX
Anatomy of a Build Pipeline
PPTX
Using protractor to build automated ui tests
PDF
Java Test Automation for REST, Web and Mobile
PDF
Continous Delivering a PHP application
PPTX
Automated Smoke Tests with Protractor
PPT
Watir Presentation Sumanth Krishna. A
PDF
Browser_Stack_Intro
PPT
Continuous Integration using Cruise Control
PPTX
Selenium
PDF
Release with confidence
PDF
One commit, one release. Continuously delivering a Symfony project.
PDF
Front-End Testing: Demystified
PDF
Run your Appium tests using Docker Android - AppiumConf 2019
PDF
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
PPT
Pragmatic Parallels: Java and JavaScript
PDF
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
 
PPTX
Supermondays: Jenkins CI lightning talk
Android UI Testing with Appium
RichFaces - Testing on Mobile Devices
Good practices for debugging Selenium and Appium tests
Anatomy of a Build Pipeline
Using protractor to build automated ui tests
Java Test Automation for REST, Web and Mobile
Continous Delivering a PHP application
Automated Smoke Tests with Protractor
Watir Presentation Sumanth Krishna. A
Browser_Stack_Intro
Continuous Integration using Cruise Control
Selenium
Release with confidence
One commit, one release. Continuously delivering a Symfony project.
Front-End Testing: Demystified
Run your Appium tests using Docker Android - AppiumConf 2019
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
Pragmatic Parallels: Java and JavaScript
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
 
Supermondays: Jenkins CI lightning talk
Ad

Recently uploaded (20)

PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Geodesy 1.pptx...............................................
PDF
composite construction of structures.pdf
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
web development for engineering and engineering
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Well-logging-methods_new................
PPTX
additive manufacturing of ss316l using mig welding
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Welding lecture in detail for understanding
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Geodesy 1.pptx...............................................
composite construction of structures.pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Arduino robotics embedded978-1-4302-3184-4.pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
web development for engineering and engineering
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Well-logging-methods_new................
additive manufacturing of ss316l using mig welding
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Welding lecture in detail for understanding
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Construction Project Organization Group 2.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Operating System & Kernel Study Guide-1 - converted.pdf

End to-end testing from rookie to pro

  • 1. End-to-end testing: from rookie to pro Domenico Gemoli - @aberonni
  • 2. Overview. ● What is end-to-end testing? ● Setup a test suite with WebdriverIO ● WebdriverIO under the hood ● Augment WebdriverIO with 3rd party tools ● Advanced techniques for end-to-end testing
  • 4. End-to-end testing is a technique used to test whether the flow of an application, from start to finish, is behaving as expected
  • 5. ● Fail fast and catch bugs before going to production ● Increase “Developer Confidence” - code fearlessly and let the tests tell you if something is broken ● Maintain quality without forcing people to do numerous rounds of manual testing
  • 6. 1. Push to Git server 2. Build commit in CI server (Travis/Jenkins/TeamCity etc…) 3. Deploy built code to a testing/staging server 4. Run end-to-end test suite on that server 5. Report test status to monitoring tools Build Deploy Test ReportPush Ideal CI workflow
  • 7. Why WebdriverIO? Written in Javascript with an easy API to learn for those with experience in unit testing Based on the WebDriver protocol which means solid drivers and easy-ish cross-browser testing Active community that continuously improves the framework and ships new features
  • 8. Setup a test suite with WebdriverIO
  • 9. Learn the basics: http://webdriver.io/guide.html Deep dive into the API: http://webdriver.io/api.html
  • 10. Prerequisites. ● Basic JS knowledge ● Node ● Java (optional, only for cross-browser testing) ● At least one browser installed
  • 11. $ mkdir webdriverio-example $ cd webdriverio-example $ npm init -y $ npm install webdriverio --save-dev $ npx wdio config
  • 13. const { assert } = require('chai'); describe('contact form', function() { it('opens alert', function() { // test script }); });
  • 14. // test script browser.url('/'); $('input#email').setValue('charlie@gmail.com'); $('textarea#message').setValue('Hello World!'); $('input[type="submit"]').click(); assert.equal( browser.alertText(), `charlie@gmail.com says 'Hello World!'` );
  • 19. “This sounds like a lot of work. Isn’t there an easy way to get this all setup?”
  • 21. 3rd party tools Use physical or emulated mobile devices to run your tests Manage your selenium grid and record videos of your tests Proprietary solutions to offload the work of setting up Zalenium.
  • 22. A flexible and scalable container based Selenium Grid with video recording, live preview, basic auth & dashboard. Docker and kubernetes support out of the box.
  • 23. Cloud web and mobile testing platform - test across on-demand browsers, operating systems and real mobile devices, without installing or maintaining virtual machines, devices or emulators
  • 24. Appium is an open-source tool for automating native, mobile web, and hybrid applications on iOS mobile, Android mobile, and Windows desktop platforms.
  • 26. VRT A11y Video Audio Take screenshots during tests and implement visual regression testing Test web page for a11y violations by injecting Axe into the page Test whether a video is playing or not, by using the video’s ‘paused’ attribute Test whether audio is playing or not, by injecting an extension on the fly Advanced techniques for testing trickier elements
  • 27. VRT. Take screenshots and compare them with baseline. Easily catch visual regressions and bugs introduced by generic CSS changes.
  • 28. // array of diff results // one result for each viewport size const results = browser.checkElement('#footer'); const isExactSameImage = results.every( result => result.isExactSameImage ); assert.ok(isExactSameImage, 'footer has not changed');
  • 29. A11y testing with Axe. Inject the axe-core library into a web page. Then use the axe-core library to analyze the website and detect a11y violations.
  • 30. const axeSource = require('axe-core').source; browser.execute(axeSource); const res = browser.executeAsync(function(done) { axe.run(function(err, results) { if (err) done(err); done(results); }); }); assert.lengthOf(res.value.violations, 0);
  • 31. Video. The easiest and most reliable way to test video: just check the ‘paused’ attribute. Having tried various techniques, this is the simplest and has never failed me
  • 32. const isVideoPaused = browser.selectorExecute( '#video', // executes the following in the browser context // videos is an array of elements corresponding // to the given selector, just retrieve the // `paused` state of the first video. videos => videos[0].paused ); assert.ok(!isVideoPaused, `video is playing`);
  • 33. Audio. Inject a chrome extension on the fly. The extension will leverage the chrome API to inject a DOM element when sound is playing on the current tab. Then simply check whether the DOM element is present.
  • 34. // snippet from extension chrome.runtime.onMessage.addListener(request => { if (request.audible) { el.className = isPlayingAudioClass; } else { el.className = ''; } });
  • 35. // element injected by the extension // if audio is playing const isPlayingAudio = browser.isExisting(isPlayingAudioClass); assert(isPlayingAudio, 'audio is playing');
  • 37. You “Shouldn’t we rather invest time in unit and integration tests?.”
  • 40. The testing pyramid tricks us into thinking that unit tests are more important than end-to-end tests, and that, if we have to choose, we should choose unit tests.
  • 41. The truth is that the testing pyramid is telling us that we should prioritise unit tests. If forced to choose, you should prefer to rely on end-to-end tests because they are closest to the customer.
  • 42. Me again “Any test is better than no tests.”