SlideShare a Scribd company logo
Backstop JS
Visual Testing
1
I would define visual testing as using a headless browser to capture and
compare images of components of a website.
This can be used to implement unit tests for how the CSS is rendering the HTML
in a browser.
Not intended to test how the HTML is generated or replace Unit tests in a back
end service layer.
Not intended to replace cross browser testing.
Allows comparison between sites or comparing against a reference image
captured form the same site before changes were made.
What do you mean by Visual
Testing ?
1. Chrome Headless
2. Setup and Examples
3. What to test
4. Setup in your project
Contents :
Chrome Headless
3
What has changed ?
Why is this a big deal ?
4
 Headless Chrome is shipping in Chrome 59. It's a way to run the Chrome
browser in a headless environment. Essentially, running Chrome without
chrome! It brings all modern web platform features provided by Chromium
and the Blink rendering engine to the command line.
Why is that useful?
A headless browser is a great tool for automated testing and server
environments where you don't need a visible UI shell. For example, you may
want to run some tests against a real web page, create a PDF of it, or just
inspect how the browser renders an URL.
Announcement blog :
https://developers.google.com/web/updates/2017/04/headless-chrome
How to Get it:
As long as you have a version of chrome installed greater than Chrome 59 –
( Chrome 61 on Windows) you already have it 
Chrome Headless
5
 BackstopJS automates visual regression testing of your responsive web UI by
comparing DOM screenshots over time.
Backstop is a open source project to run visual tests using headless browsers to
capture screenshots.
Originally ran using either PhantomJS or SlimerJS headless browser libraries.
These were implementations of WebKit (Chrome) or Gecko (Firefox).
From release v3.0.19 this now supports Chrome headless.
The latest release has a lot of stability improvements v3.0.27
Git Hub URL : https://github.com/garris/BackstopJS
Features :
• Allows capture and comparison of screenshots form headless browser
• Excellent comparison tool to identify and highlight differences
• Allows setup of multiple breakpoints to test responsive sites
• Uses simple CSS selectors to identify what to capture
• Pre capture scripts can be enabled to be ran
Backstop JS
6
Chrome is based on WebKit but using PhantomJS as a headless browser
caused issues making it unusable.
There would be styling issues that would be thrown that would not be present on
the site when viewed through chrome.
As visual testing is about how the site renders this causes the tests to be
unreliable.
When I investigated implementing visual testing this was the stumbling block
each time.
Chrome != Webkit
Setup and Examples
7
8
• backstop init : Set up a new BackstopJS instance -- specify URLs, cookies,
screen sizes, DOM selectors, interactions etc. (see examples directory)
• backstop test : BackstopJS creates a set of test screenshots and compares
them with your reference screenshots. Any changes show up in a visual
report. (Run this after making CSS changes as many times as needed.)
• backstop approve : If the test you ran looks good, then go ahead and
approve it. Approving changes will update your reference files with the
results from your last test. Future tests are compared against your most
recent approved test screenshots.
The BackstopJS workflow
9
backstop init
10
backstop test (initial)
11
backstop approve
12
backstop test
13
{
"id": "backstop_default",
"viewports": [
{
"label": "phone",
"width": 320,
"height": 480
},
{
"label": "tablet",
"width": 1024,
"height": 768
}
],
"onBeforeScript": "chromy/onBefore.js",
"onReadyScript": "chromy/onReady.js",
"scenarios": [
…………
],
"paths": {
"bitmaps_reference": "backstop_data/bitmaps_reference",
"bitmaps_test": "backstop_data/bitmaps_test",
"engine_scripts": "backstop_data/engine_scripts",
"html_report": "backstop_data/html_report",
"ci_report": "backstop_data/ci_report"
},
"report": ["browser"],
"engine": "chrome",
"engineFlags": [],
"asyncCaptureLimit": 5,
"asyncCompareLimit": 50,
"debug": false,
"debugWindow": false
}
Default Configuration
{
"label": "BackstopJS Homepage",
"cookiePath": "backstop_data/engine_scripts/cookies.json",
"url": "https://garris.github.io/BackstopJS/",
"referenceUrl": "",
"readyEvent": "",
"readySelector": "",
"delay": 0,
"hideSelectors": [],
"removeSelectors": [],
"hoverSelector": "",
"clickSelector": "",
"postInteractionWait": "",
"selectors": [],
"selectorExpansion": true,
"misMatchThreshold" : 0.1,
"requireSameDimensions": true
}
14
On the CIPD PM build we have incorporated it in to the HTML dev process.
When components are created a new test scenario is added to the backstop
tests.
This captures the components from the locally setup demo site.
This creates a reference image for that component that is then checked in to
source control.
Project Setup
What to Test
15
16
Visual regression testing is the process of creating reference images for each
component as they are created. This allows a comparison over time to monitor
changes.
Ran by the developer on their local development environment after changes
made to ensure no regressions issues have occurred due to their changes.
Why is that useful?
• This allows the developer greater test coverage than they could do manually
when ensuring their changes have not had regression impact on other
components.
• Allows greater detail comparison than possible reviewing the site manually.
E.g. If the font size is increased by 1px then it will be caught which could
easily be missed.
• Allows developers without a full understanding of the project have a safety
net about what the site should look like before their changes.
Visual Regression Testing
17
Using visual testing to compare different environments involves comparing one
site against another . The reference images are not stored beyond the test.
A reference image set is generated form one site and then another site is
compared against them
Why is that useful?
• To ensure that the HTML created has been integrated within the website
correctly and is rendering out in the same way. This highlights mistakes with
the integration or conflicting integrations that are not present on the HTML
Demo site.
• Running regression tests against the Staging and Live instances of a site to
see where the changes have occurred.
• When setting up comparison between a demo and dev site powered by a
CMS this can make the tests brittle so the tests pages need to be isolated
from changes in content as possible.
Environment Comparison
18
Within a site their are hover states and interactive components. These need the
mouse or user interactions to trigger them.
How to test these in a headless browser?
Backstop allows scripts to be ran before a screenshot is captured. Using the
chromy API you can move the mouse and manipulate the page through script.
This allows testing of :
• Field entry
• Hover states
• Interactive items
• Video loading – Playing
• Ajax content loading
Chromy Git Hub URL : https://github.com/OnetapInc/chromy
Interacting with the site
19
When capturing items it is much quicker to capture components on a page than
the whole page to compare them
• It is much quicker to compare the smaller images
• It is more relevant the items that are being tested.
This allows the components themselves to be bested in isolation and most of our
development work is done using component based development.
Smaller is better
Setup in your project
20
Process to include in you
project
21
Install
Backstop
init within you
project Create
scenarios
Run Baseline
generation
Keep running
and
monitoring
22
Prerequisites
• Node – (If you don’t already have it)
• Chrome - (61 needed but latest is 62.0.3202.62 at the moment)
• Update node to v8+
• Update npm to v5+
On Windows you will also need to have python installed
> PhantomJS needs Python -- please make sure you have Python installed...
see https://github.com/garris/BackstopJS/issues/185
Installation
• npm install -g backstopjs
• Installs backstop globally
This allows the backstop command to be ran from anywhere on the PC.
Install Backstop - Globally
23
Backstop can also be installed as a grunt dependency and called through grunt.
var backstopjs = require('backstopjs');
grunt.registerTask('backstop', 'BackstopJS integration', function(cmd) {
// cmd is either 'reference', 'test', or 'openReport'
var done = this.async();
backstopjs(cmd).then(function() {
done(true);
}).catch(function() {
done(false);
});
});
This allows it to be integrated in to the existing grunt tasks.
Including it in grunt also allows the dynamic creation of the scenarios using
variables instead of them being held in a JSON file.
Installing Backtop in Grunt
24
There is a basic backstop.json file that is created when you run backstop init.
This can be edited to add in your own scenarios.
This is an example of the setup we are using.
Key Points:
• The Viewports are defined for use in all tests
• resembleOutputOptions define the comparison colours and display style
• The asyncCaptureLimit and asyncCompareLimit are used to control the
number of threads and memory the tests use.
• "engine": "chrome“ defines that the chrome headless browser will be used.
Configuration Setup
{
"id": "pm",
"viewports": [
{
"label": "phone",
"width": 320,
"height": 1024
},
{
"label": "tablet",
"width": 768,
"height": 1024
},
{
"label": "desktop",
"width": 1268,
"height": 1024
}
],
"onBeforeScript": "chromy/onBefore.js",
"onReadyScript": "chromy/onReady.js",
"scenarios": [
{
……..
}
],
"resembleOutputOptions": {
"errorColor": {
"red": 255,
"green": 0,
"blue": 255
},
"errorType": "movement",
"transparency": 0.3,
"ignoreAntialiasing" : true
},
"asyncCaptureLimit": 25,
"asyncCompareLimit": 400,
"engineFlags": [],
"engine": "chrome",
"report": ["browser","CI"],
"debug": false,
"debugWindow": false
}
25
For scenarios setup there are two key parameters :
• url
• selectors
These define the page the what will be captured on the page. The selectors
used simple CSS selectors to identify elements on the page to capture.
To capture the contents of the <div id=“header”> then the #header is used as a
selector.
If a referenceUrl is specified then this will be used instead of the url when
generating the reference images. This is used when comparing sites.
The hideSelectors parameter is used to define the elements on the page that
should not be shown. This is useful to hide cookie notifications for example that
could obscure capture of components.
Scenario Setup
{
"label": "header",
"url": "http://people-management.local/bb-prototype-
website_example_grid.html",
"selectors": [
"#header"
],
"hideSelectors": [
"#monitor_mq",
".grid",
".visible-grid-btn"
],
"readySelector": ".page-loaded“
},
{
"label": "podcast",
"url": "http://beta.pmdev.co.uk/test/podcast",
"referenceUrl": "http://internal.people-
management.demo.building-blocks.com/bb-prototype-
website_components-podcast.html",
"selectors": [
".podcast-container"
],
"hideSelectors": [
"#monitor_mq",
"#SEStartButton",
"#cookieMsgWrapper2",
".grid",
".visible-grid-btn"
]
}
26
Scenario Setup :
"onReadyScript": "burgerMenuTest.js",
Chromy Script :
module.exports = function (chromy, scenario) {
var clickSelector = scenario.clickSelector;
var postInteractionWait = scenario.postInteractionWait; // selector [str] | ms [int]
if (clickSelector) {
chromy
.wait(clickSelector)
.click(clickSelector)
}
if (postInteractionWait) {
chromy.wait(postInteractionWait);
}
};
Chromy
Backstop JS the future …..
27
• Catch Regression
• Allow comparison between DEMO HTML and Website
• Quick to setup
• Easily integrate in to existing HTML build process

More Related Content

What's hot

Webpack slides
Webpack slidesWebpack slides
Api presentation
Api presentationApi presentation
Api presentation
Tiago Cardoso
 
Progressive Web Applications
Progressive Web ApplicationsProgressive Web Applications
Progressive Web Applications
Bartek Igielski
 
Puppeteer can automate that! - Frontmania
Puppeteer can automate that! - FrontmaniaPuppeteer can automate that! - Frontmania
Puppeteer can automate that! - Frontmania
Önder Ceylan
 
Why Progressive Web App is what you need for your Business
Why Progressive Web App is what you need for your BusinessWhy Progressive Web App is what you need for your Business
Why Progressive Web App is what you need for your Business
Lets Grow Business
 
No drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwrightNo drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwright
Mastacheata1
 
Flutter
FlutterFlutter
Flutter
Mohit Sharma
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
SheilaJimenezMorejon
 
Flutter
FlutterFlutter
Firebase
FirebaseFirebase
ZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in Scala
Wiem Zine Elabidine
 
Flutter workshop
Flutter workshopFlutter workshop
Flutter workshop
Vishnu Suresh
 
Building a Progressive Web App
Building a  Progressive Web AppBuilding a  Progressive Web App
Building a Progressive Web App
Ido Green
 
Firebase
FirebaseFirebase
Firebase
Shady Selim
 
Introduction of Progressive Web App
Introduction of Progressive Web AppIntroduction of Progressive Web App
Introduction of Progressive Web App
Sankalp Khandelwal
 
Flutter & Firebase BootCamp.pdf
Flutter & Firebase BootCamp.pdfFlutter & Firebase BootCamp.pdf
Flutter & Firebase BootCamp.pdf
ShivamShrey1
 
Spring Ldap
Spring LdapSpring Ldap
Spring Ldap
Piergiorgio Lucidi
 
Basics of VueJS
Basics of VueJSBasics of VueJS
Basics of VueJS
Squash Apps Pvt Ltd
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patterns
José Paumard
 
Cross browser testing with browser stack
Cross browser testing with browser stackCross browser testing with browser stack
Cross browser testing with browser stack
Denys Poloka
 

What's hot (20)

Webpack slides
Webpack slidesWebpack slides
Webpack slides
 
Api presentation
Api presentationApi presentation
Api presentation
 
Progressive Web Applications
Progressive Web ApplicationsProgressive Web Applications
Progressive Web Applications
 
Puppeteer can automate that! - Frontmania
Puppeteer can automate that! - FrontmaniaPuppeteer can automate that! - Frontmania
Puppeteer can automate that! - Frontmania
 
Why Progressive Web App is what you need for your Business
Why Progressive Web App is what you need for your BusinessWhy Progressive Web App is what you need for your Business
Why Progressive Web App is what you need for your Business
 
No drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwrightNo drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwright
 
Flutter
FlutterFlutter
Flutter
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
 
Flutter
FlutterFlutter
Flutter
 
Firebase
FirebaseFirebase
Firebase
 
ZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in Scala
 
Flutter workshop
Flutter workshopFlutter workshop
Flutter workshop
 
Building a Progressive Web App
Building a  Progressive Web AppBuilding a  Progressive Web App
Building a Progressive Web App
 
Firebase
FirebaseFirebase
Firebase
 
Introduction of Progressive Web App
Introduction of Progressive Web AppIntroduction of Progressive Web App
Introduction of Progressive Web App
 
Flutter & Firebase BootCamp.pdf
Flutter & Firebase BootCamp.pdfFlutter & Firebase BootCamp.pdf
Flutter & Firebase BootCamp.pdf
 
Spring Ldap
Spring LdapSpring Ldap
Spring Ldap
 
Basics of VueJS
Basics of VueJSBasics of VueJS
Basics of VueJS
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patterns
 
Cross browser testing with browser stack
Cross browser testing with browser stackCross browser testing with browser stack
Cross browser testing with browser stack
 

Similar to Technical Tips: Visual Regression Testing and Environment Comparison with Backstop.JS

[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design
Christopher Schmitt
 
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
Christopher Schmitt
 
vodQA Pune (2019) - Browser automation using dev tools
vodQA Pune (2019) - Browser automation using dev toolsvodQA Pune (2019) - Browser automation using dev tools
vodQA Pune (2019) - Browser automation using dev tools
vodQA
 
Making Chrome Extension with AngularJS
Making Chrome Extension with AngularJSMaking Chrome Extension with AngularJS
Making Chrome Extension with AngularJS
Ben Lau
 
[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design
Christopher Schmitt
 
New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)
jeresig
 
Panther loves Symfony apps
Panther loves Symfony appsPanther loves Symfony apps
Panther loves Symfony apps
Simone D'Amico
 
Puppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node APIPuppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node API
ubunturk
 
An Introduction to Web Components
An Introduction to Web ComponentsAn Introduction to Web Components
An Introduction to Web Components
Red Pill Now
 
How To Automate Cross Browser Testing
How To Automate Cross Browser TestingHow To Automate Cross Browser Testing
How To Automate Cross Browser Testing
Daniel Herken
 
Tips for Developing and Testing IBM HATS Applications
Tips for Developing and Testing IBM HATS ApplicationsTips for Developing and Testing IBM HATS Applications
Tips for Developing and Testing IBM HATS Applications
Strongback Consulting
 
Android Chromium Rendering Pipeline
Android Chromium Rendering PipelineAndroid Chromium Rendering Pipeline
Android Chromium Rendering Pipeline
Hyungwook Lee
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
David Amend
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
Yan Shi
 
Web app and more
Web app and moreWeb app and more
Web app and more
faming su
 
Be ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orruBe ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orru
Michele Orru
 
An introduction to PhantomJS: A headless browser for automation test.
An introduction to PhantomJS: A headless browser for automation test.An introduction to PhantomJS: A headless browser for automation test.
An introduction to PhantomJS: A headless browser for automation test.
BugRaptors
 
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsers
Sergey Shekyan
 
Building Web Sites that Work Everywhere
Building Web Sites that Work EverywhereBuilding Web Sites that Work Everywhere
Building Web Sites that Work Everywhere
Doris Chen
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascript
Timothy Oxley
 

Similar to Technical Tips: Visual Regression Testing and Environment Comparison with Backstop.JS (20)

[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design
 
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
 
vodQA Pune (2019) - Browser automation using dev tools
vodQA Pune (2019) - Browser automation using dev toolsvodQA Pune (2019) - Browser automation using dev tools
vodQA Pune (2019) - Browser automation using dev tools
 
Making Chrome Extension with AngularJS
Making Chrome Extension with AngularJSMaking Chrome Extension with AngularJS
Making Chrome Extension with AngularJS
 
[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design
 
New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)
 
Panther loves Symfony apps
Panther loves Symfony appsPanther loves Symfony apps
Panther loves Symfony apps
 
Puppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node APIPuppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node API
 
An Introduction to Web Components
An Introduction to Web ComponentsAn Introduction to Web Components
An Introduction to Web Components
 
How To Automate Cross Browser Testing
How To Automate Cross Browser TestingHow To Automate Cross Browser Testing
How To Automate Cross Browser Testing
 
Tips for Developing and Testing IBM HATS Applications
Tips for Developing and Testing IBM HATS ApplicationsTips for Developing and Testing IBM HATS Applications
Tips for Developing and Testing IBM HATS Applications
 
Android Chromium Rendering Pipeline
Android Chromium Rendering PipelineAndroid Chromium Rendering Pipeline
Android Chromium Rendering Pipeline
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
Be ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orruBe ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orru
 
An introduction to PhantomJS: A headless browser for automation test.
An introduction to PhantomJS: A headless browser for automation test.An introduction to PhantomJS: A headless browser for automation test.
An introduction to PhantomJS: A headless browser for automation test.
 
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsers
 
Building Web Sites that Work Everywhere
Building Web Sites that Work EverywhereBuilding Web Sites that Work Everywhere
Building Web Sites that Work Everywhere
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascript
 

More from Building Blocks

Transforming to a new Digital DNA
Transforming to a new Digital DNATransforming to a new Digital DNA
Transforming to a new Digital DNA
Building Blocks
 
Digital Foundations: 3 Simple Steps to Changing your Digital DNA
Digital Foundations: 3 Simple Steps to Changing your Digital DNADigital Foundations: 3 Simple Steps to Changing your Digital DNA
Digital Foundations: 3 Simple Steps to Changing your Digital DNA
Building Blocks
 
How to create a compelling business case for Digital Transformation
How to create a compelling business case for Digital TransformationHow to create a compelling business case for Digital Transformation
How to create a compelling business case for Digital Transformation
Building Blocks
 
Transforming One Small Step At A Time: Optimisation & Testing
Transforming One Small Step At A Time: Optimisation & TestingTransforming One Small Step At A Time: Optimisation & Testing
Transforming One Small Step At A Time: Optimisation & Testing
Building Blocks
 
Tackling 8 Digital Challenges of the Agrochemical, Industrial & Specialty Che...
Tackling 8 Digital Challenges of the Agrochemical, Industrial & Specialty Che...Tackling 8 Digital Challenges of the Agrochemical, Industrial & Specialty Che...
Tackling 8 Digital Challenges of the Agrochemical, Industrial & Specialty Che...
Building Blocks
 
The importance of testing in a web design & build project
The importance of testing in a web design & build projectThe importance of testing in a web design & build project
The importance of testing in a web design & build project
Building Blocks
 
Going Digital First with Publishing for Lloyd's Register
Going Digital First with Publishing for Lloyd's RegisterGoing Digital First with Publishing for Lloyd's Register
Going Digital First with Publishing for Lloyd's Register
Building Blocks
 
Accelerating Eurocamp's Digital Transformation
Accelerating Eurocamp's Digital TransformationAccelerating Eurocamp's Digital Transformation
Accelerating Eurocamp's Digital Transformation
Building Blocks
 

More from Building Blocks (8)

Transforming to a new Digital DNA
Transforming to a new Digital DNATransforming to a new Digital DNA
Transforming to a new Digital DNA
 
Digital Foundations: 3 Simple Steps to Changing your Digital DNA
Digital Foundations: 3 Simple Steps to Changing your Digital DNADigital Foundations: 3 Simple Steps to Changing your Digital DNA
Digital Foundations: 3 Simple Steps to Changing your Digital DNA
 
How to create a compelling business case for Digital Transformation
How to create a compelling business case for Digital TransformationHow to create a compelling business case for Digital Transformation
How to create a compelling business case for Digital Transformation
 
Transforming One Small Step At A Time: Optimisation & Testing
Transforming One Small Step At A Time: Optimisation & TestingTransforming One Small Step At A Time: Optimisation & Testing
Transforming One Small Step At A Time: Optimisation & Testing
 
Tackling 8 Digital Challenges of the Agrochemical, Industrial & Specialty Che...
Tackling 8 Digital Challenges of the Agrochemical, Industrial & Specialty Che...Tackling 8 Digital Challenges of the Agrochemical, Industrial & Specialty Che...
Tackling 8 Digital Challenges of the Agrochemical, Industrial & Specialty Che...
 
The importance of testing in a web design & build project
The importance of testing in a web design & build projectThe importance of testing in a web design & build project
The importance of testing in a web design & build project
 
Going Digital First with Publishing for Lloyd's Register
Going Digital First with Publishing for Lloyd's RegisterGoing Digital First with Publishing for Lloyd's Register
Going Digital First with Publishing for Lloyd's Register
 
Accelerating Eurocamp's Digital Transformation
Accelerating Eurocamp's Digital TransformationAccelerating Eurocamp's Digital Transformation
Accelerating Eurocamp's Digital Transformation
 

Recently uploaded

A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 

Recently uploaded (20)

A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 

Technical Tips: Visual Regression Testing and Environment Comparison with Backstop.JS

  • 2. 1 I would define visual testing as using a headless browser to capture and compare images of components of a website. This can be used to implement unit tests for how the CSS is rendering the HTML in a browser. Not intended to test how the HTML is generated or replace Unit tests in a back end service layer. Not intended to replace cross browser testing. Allows comparison between sites or comparing against a reference image captured form the same site before changes were made. What do you mean by Visual Testing ?
  • 3. 1. Chrome Headless 2. Setup and Examples 3. What to test 4. Setup in your project Contents :
  • 4. Chrome Headless 3 What has changed ? Why is this a big deal ?
  • 5. 4  Headless Chrome is shipping in Chrome 59. It's a way to run the Chrome browser in a headless environment. Essentially, running Chrome without chrome! It brings all modern web platform features provided by Chromium and the Blink rendering engine to the command line. Why is that useful? A headless browser is a great tool for automated testing and server environments where you don't need a visible UI shell. For example, you may want to run some tests against a real web page, create a PDF of it, or just inspect how the browser renders an URL. Announcement blog : https://developers.google.com/web/updates/2017/04/headless-chrome How to Get it: As long as you have a version of chrome installed greater than Chrome 59 – ( Chrome 61 on Windows) you already have it  Chrome Headless
  • 6. 5  BackstopJS automates visual regression testing of your responsive web UI by comparing DOM screenshots over time. Backstop is a open source project to run visual tests using headless browsers to capture screenshots. Originally ran using either PhantomJS or SlimerJS headless browser libraries. These were implementations of WebKit (Chrome) or Gecko (Firefox). From release v3.0.19 this now supports Chrome headless. The latest release has a lot of stability improvements v3.0.27 Git Hub URL : https://github.com/garris/BackstopJS Features : • Allows capture and comparison of screenshots form headless browser • Excellent comparison tool to identify and highlight differences • Allows setup of multiple breakpoints to test responsive sites • Uses simple CSS selectors to identify what to capture • Pre capture scripts can be enabled to be ran Backstop JS
  • 7. 6 Chrome is based on WebKit but using PhantomJS as a headless browser caused issues making it unusable. There would be styling issues that would be thrown that would not be present on the site when viewed through chrome. As visual testing is about how the site renders this causes the tests to be unreliable. When I investigated implementing visual testing this was the stumbling block each time. Chrome != Webkit
  • 9. 8 • backstop init : Set up a new BackstopJS instance -- specify URLs, cookies, screen sizes, DOM selectors, interactions etc. (see examples directory) • backstop test : BackstopJS creates a set of test screenshots and compares them with your reference screenshots. Any changes show up in a visual report. (Run this after making CSS changes as many times as needed.) • backstop approve : If the test you ran looks good, then go ahead and approve it. Approving changes will update your reference files with the results from your last test. Future tests are compared against your most recent approved test screenshots. The BackstopJS workflow
  • 14. 13 { "id": "backstop_default", "viewports": [ { "label": "phone", "width": 320, "height": 480 }, { "label": "tablet", "width": 1024, "height": 768 } ], "onBeforeScript": "chromy/onBefore.js", "onReadyScript": "chromy/onReady.js", "scenarios": [ ………… ], "paths": { "bitmaps_reference": "backstop_data/bitmaps_reference", "bitmaps_test": "backstop_data/bitmaps_test", "engine_scripts": "backstop_data/engine_scripts", "html_report": "backstop_data/html_report", "ci_report": "backstop_data/ci_report" }, "report": ["browser"], "engine": "chrome", "engineFlags": [], "asyncCaptureLimit": 5, "asyncCompareLimit": 50, "debug": false, "debugWindow": false } Default Configuration { "label": "BackstopJS Homepage", "cookiePath": "backstop_data/engine_scripts/cookies.json", "url": "https://garris.github.io/BackstopJS/", "referenceUrl": "", "readyEvent": "", "readySelector": "", "delay": 0, "hideSelectors": [], "removeSelectors": [], "hoverSelector": "", "clickSelector": "", "postInteractionWait": "", "selectors": [], "selectorExpansion": true, "misMatchThreshold" : 0.1, "requireSameDimensions": true }
  • 15. 14 On the CIPD PM build we have incorporated it in to the HTML dev process. When components are created a new test scenario is added to the backstop tests. This captures the components from the locally setup demo site. This creates a reference image for that component that is then checked in to source control. Project Setup
  • 17. 16 Visual regression testing is the process of creating reference images for each component as they are created. This allows a comparison over time to monitor changes. Ran by the developer on their local development environment after changes made to ensure no regressions issues have occurred due to their changes. Why is that useful? • This allows the developer greater test coverage than they could do manually when ensuring their changes have not had regression impact on other components. • Allows greater detail comparison than possible reviewing the site manually. E.g. If the font size is increased by 1px then it will be caught which could easily be missed. • Allows developers without a full understanding of the project have a safety net about what the site should look like before their changes. Visual Regression Testing
  • 18. 17 Using visual testing to compare different environments involves comparing one site against another . The reference images are not stored beyond the test. A reference image set is generated form one site and then another site is compared against them Why is that useful? • To ensure that the HTML created has been integrated within the website correctly and is rendering out in the same way. This highlights mistakes with the integration or conflicting integrations that are not present on the HTML Demo site. • Running regression tests against the Staging and Live instances of a site to see where the changes have occurred. • When setting up comparison between a demo and dev site powered by a CMS this can make the tests brittle so the tests pages need to be isolated from changes in content as possible. Environment Comparison
  • 19. 18 Within a site their are hover states and interactive components. These need the mouse or user interactions to trigger them. How to test these in a headless browser? Backstop allows scripts to be ran before a screenshot is captured. Using the chromy API you can move the mouse and manipulate the page through script. This allows testing of : • Field entry • Hover states • Interactive items • Video loading – Playing • Ajax content loading Chromy Git Hub URL : https://github.com/OnetapInc/chromy Interacting with the site
  • 20. 19 When capturing items it is much quicker to capture components on a page than the whole page to compare them • It is much quicker to compare the smaller images • It is more relevant the items that are being tested. This allows the components themselves to be bested in isolation and most of our development work is done using component based development. Smaller is better
  • 21. Setup in your project 20
  • 22. Process to include in you project 21 Install Backstop init within you project Create scenarios Run Baseline generation Keep running and monitoring
  • 23. 22 Prerequisites • Node – (If you don’t already have it) • Chrome - (61 needed but latest is 62.0.3202.62 at the moment) • Update node to v8+ • Update npm to v5+ On Windows you will also need to have python installed > PhantomJS needs Python -- please make sure you have Python installed... see https://github.com/garris/BackstopJS/issues/185 Installation • npm install -g backstopjs • Installs backstop globally This allows the backstop command to be ran from anywhere on the PC. Install Backstop - Globally
  • 24. 23 Backstop can also be installed as a grunt dependency and called through grunt. var backstopjs = require('backstopjs'); grunt.registerTask('backstop', 'BackstopJS integration', function(cmd) { // cmd is either 'reference', 'test', or 'openReport' var done = this.async(); backstopjs(cmd).then(function() { done(true); }).catch(function() { done(false); }); }); This allows it to be integrated in to the existing grunt tasks. Including it in grunt also allows the dynamic creation of the scenarios using variables instead of them being held in a JSON file. Installing Backtop in Grunt
  • 25. 24 There is a basic backstop.json file that is created when you run backstop init. This can be edited to add in your own scenarios. This is an example of the setup we are using. Key Points: • The Viewports are defined for use in all tests • resembleOutputOptions define the comparison colours and display style • The asyncCaptureLimit and asyncCompareLimit are used to control the number of threads and memory the tests use. • "engine": "chrome“ defines that the chrome headless browser will be used. Configuration Setup { "id": "pm", "viewports": [ { "label": "phone", "width": 320, "height": 1024 }, { "label": "tablet", "width": 768, "height": 1024 }, { "label": "desktop", "width": 1268, "height": 1024 } ], "onBeforeScript": "chromy/onBefore.js", "onReadyScript": "chromy/onReady.js", "scenarios": [ { …….. } ], "resembleOutputOptions": { "errorColor": { "red": 255, "green": 0, "blue": 255 }, "errorType": "movement", "transparency": 0.3, "ignoreAntialiasing" : true }, "asyncCaptureLimit": 25, "asyncCompareLimit": 400, "engineFlags": [], "engine": "chrome", "report": ["browser","CI"], "debug": false, "debugWindow": false }
  • 26. 25 For scenarios setup there are two key parameters : • url • selectors These define the page the what will be captured on the page. The selectors used simple CSS selectors to identify elements on the page to capture. To capture the contents of the <div id=“header”> then the #header is used as a selector. If a referenceUrl is specified then this will be used instead of the url when generating the reference images. This is used when comparing sites. The hideSelectors parameter is used to define the elements on the page that should not be shown. This is useful to hide cookie notifications for example that could obscure capture of components. Scenario Setup { "label": "header", "url": "http://people-management.local/bb-prototype- website_example_grid.html", "selectors": [ "#header" ], "hideSelectors": [ "#monitor_mq", ".grid", ".visible-grid-btn" ], "readySelector": ".page-loaded“ }, { "label": "podcast", "url": "http://beta.pmdev.co.uk/test/podcast", "referenceUrl": "http://internal.people- management.demo.building-blocks.com/bb-prototype- website_components-podcast.html", "selectors": [ ".podcast-container" ], "hideSelectors": [ "#monitor_mq", "#SEStartButton", "#cookieMsgWrapper2", ".grid", ".visible-grid-btn" ] }
  • 27. 26 Scenario Setup : "onReadyScript": "burgerMenuTest.js", Chromy Script : module.exports = function (chromy, scenario) { var clickSelector = scenario.clickSelector; var postInteractionWait = scenario.postInteractionWait; // selector [str] | ms [int] if (clickSelector) { chromy .wait(clickSelector) .click(clickSelector) } if (postInteractionWait) { chromy.wait(postInteractionWait); } }; Chromy
  • 28. Backstop JS the future ….. 27 • Catch Regression • Allow comparison between DEMO HTML and Website • Quick to setup • Easily integrate in to existing HTML build process