visual regression testing

36
VISUAL REGRESSION TESTING USING GALEN JYOTHY MARIAM JOHN, RISHABH RAO 16TH JULY 2016

Upload: vodqablr

Post on 05-Apr-2017

266 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Visual Regression Testing

VISUAL REGRESSION TESTING USING GALENJYOTHY MARIAM JOHN, RISHABH RAO

16TH JULY 2016

Page 2: Visual Regression Testing

Change BlindnessChange blindness is a surprising perceptual phenomenon

that occurs when a change in a visual stimulus is introduced and the observer does not notice it. https://www.youtube.com/watch?v=ubNF9QNEQLA

Page 3: Visual Regression Testing

Visual regression tests

Tests the layout of a page, the way in which components - texts, images, grids etc are set out on a page.

Functional Test will pass for both the cases though layout is broken in the second image. NOTE: Tooltip error message is overlapping text box

Page 4: Visual Regression Testing

Why Visual regression tests?

CI / CD Environment - Frequent Releases

Responsive Web Design

Themes / Skins

Page 5: Visual Regression Testing

Responsive Web Design

Responsive web design (RWD) is an approach to web design aimed at crafting sites to provide an optimal viewing and interaction experience—easy reading and navigation with a minimum of resizing, panning, and scrolling—across a wide range of devices (from desktop computer monitors to mobile phones)

Page 6: Visual Regression Testing

Themes / Skins

Applying a skin changes a piece of software's look and feel—some skins merely make the program more aesthetically pleasing, but others can rearrange elements of the interface, potentially making the program easier to use.

Page 7: Visual Regression Testing

Automated Visual Regression Tests thus become QA’s lifeline in tackling such

complexities

Page 8: Visual Regression Testing

Agenda

✓ Why visual regression tests are important

Existing tools & Overview of Galen

My journey, challenges faced / learnings

Page 9: Visual Regression Testing

Galen

A test framework originally designed for testing layout of web applications. When it comes to testing a responsive layout it works in the following way

Open a page in browserResize it to specified size

Test the layout according to user-defined specsIt uses Selenium for interacting with elements on page and getting their locations and dimensions.

Once it sees that something is wrong – Galen reports the error, makes a screenshot and highlights the misbehaving element on it.

http://galenframework.com/docs/all/

Page 10: Visual Regression Testing

Galen

Galen unlike existing image comparison tools, provides a way to test components on a page with reference to other components present.

Galen also supports image comparisons.

Page 11: Visual Regression Testing

Basics

Galen CommandsGalen Specification FileGalen Reports

Galen commands refer spec file for page validation

Page 12: Visual Regression Testing

Spec File Format

Object Definitions, for Galen to find elements on test page. Supported locators are id, css & xpath

Spec Sections, for describing the page layout for each viewport size using spec reference keywords like near, below, above, left-of, right-of, inside etc.

http://galenframework.com/docs/reference-galen-spec-language-guide/#SpecsReference

Page 13: Visual Regression Testing

Sample Spec File

Page 14: Visual Regression Testing

Spec Reference

Or be less strict and saynear button 5 to 15 px left

Page 15: Visual Regression Testing

CSS Property

Test the value of a CSS property for a specific element

Page 16: Visual Regression Testing

Image

Supports Image Comparison

Reports error if mismatching pixels are more than acceptable range 12%

The red pixels on comparison map are the mismatching pixels that are far away from tolerance value, yellow pixels are in the range of 30 to 80 colour difference from the tolerance value, Green pixels are the closest to tolerance value.

By default tolerance is set to 30, if we increase this parameter, the amount of mismatching pixels will be decreased

Page 17: Visual Regression Testing

Command Line Tests

In order to perform a single page test you can use the command “check”

Page 18: Visual Regression Testing

JavaScript Tests

Provides list of API’s to write JavaScript testsE.g load, createDriver, createGridDriver, resize, checkLayout, checkPageSpecLayout, parsePageSpec etcAlso provides a lightweight javascript testing framework (GalenPages) to work with page object model

test("Home page", function() {

var driver = createDriver(“http://galenframework.com","1024x768");

checkLayout(driver, "homePage.gspec", ["all", "desktop"]);

});

http://galenframework.com/docs/reference-javascript-tests-guide/

Page 19: Visual Regression Testing

Java Tests

Use Galen inside Java tests

Java + Maven + TestNG + Galen

Integrate visual regression tests into your existing functional regression tests framework and reuse navigation / actions which is already defined for existing tests

import com.galenframework.api.Galen;

Page 20: Visual Regression Testing

Agenda

✓ Why visual regression tests are important

✓ Existing tools & Overview of Galen

My journey, challenges faced / learnings

Page 21: Visual Regression Testing

Reference Tests

Page 23: Visual Regression Testing

Image Comparison

Configuration File

runMode = createBaseline / validateUI

Page 24: Visual Regression Testing

Image ComparisonChallenges

Dynamic contentVarying image colours on different screens

Page 25: Visual Regression Testing

Image RenderingDifferences

Page 26: Visual Regression Testing

Image RenderingDifferences

Page 27: Visual Regression Testing

Addressing dynamic content

Validate @Component Level

Page 28: Visual Regression Testing

Addressing dynamic content

Change RunTime Behaviour Of AUT

Page 29: Visual Regression Testing

Addressing dynamic content

Mock responses

https://github.com/mrak/stubby4node

Page 30: Visual Regression Testing

Addressing dynamic content

Inject javascript to modify the text displayed

Page 31: Visual Regression Testing

Reports

Inherit all your test class from com.galenframework.testng.GalenTestNgTestBase

Add com.galenframework.testng.GalenTestNgReportsListener in your pom file

Page 32: Visual Regression Testing

Reports

Baseline Actual Comparison Map

Page 33: Visual Regression Testing

Reports

Baseline Actual Comparison Map

Page 35: Visual Regression Testing

Error Vs Tolerance

Page 36: Visual Regression Testing

Error Vs Toleranceblues.png, tolerance 30 blues.png, tolerance 80

When tolerance is increased red area (in image2) has decreased and less error value is reportedMore the tolerance, lesser the error..