44

ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3
Page 2: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 2

CI FOR CSSCreating a Visual Regression Testing Workflow

Presented by Kate Kligman

May 13, 2015

Page 3: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 3

Visual Regression Testing?

Middle image CC by SA 3.0 Hans-Werner34 at en.wikipedia http://en.wikipedia.org/wiki/Eye_tracking#/media/File:Eye_tracking_thru_glass.JPG Snellen chart CC by SA 3.0 http://commons.wikimedia.org/wiki/File:Snellen_chart.svg

Page 4: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 4

About this Session

‣ Why visual regression testing?

‣ Headless Testing • Wraith

‣ Full Browser Testing • Selenium • WebdriverCSS

‣ Questions

Page 5: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 5

About Me

@KateKligman

Page 6: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3
Page 7: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3
Page 8: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3
Page 9: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3
Page 10: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3
Page 11: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3
Page 12: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3
Page 13: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3
Page 14: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3
Page 15: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 15

Visual Regression Testing Challenges

‣ Platform challenges • Fonts, form controls • Rendering engines

‣ Content challenges • Dynamic content • Environment setup

‣ Workflow challenges • Navigation • Baseline tracking

Page 16: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

TITLE TEXTWRAITH

Page 17: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 17

Wraith Image Gallery

Page 18: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 18

Wraith Comparisons

Page 19: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io

wraith

configs

config.yaml javascript

snap.js

shots

gallery.html

bootstrap.min.cs

thumbnails

mypage

19

Wraith Setup

Wraith Initialization

$ wraith setup

create configs/config.yaml create javascript/snap.js

Wraith Folder Structure

Each URL path gets it’s own screenshot folder.

Page 20: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 20

Wraith Configuration

browser: phantomjs (can also use slimerjs)

snap_file: javascript/snap.js

directory: shots

domains: dev: http://dev-panolopy-dreams.pantheon.io test: http://test-panolopy-dreams.pantheon.io

configs/config.yaml

Page 21: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 21

Wraith URL Configuration

paths: home: / login: /user/login great-vegetables: /content/great-vegetables lovely-vegetables: /content/lovely-vegetables

screen_widths: - 320 - 600 - 768 - 1024

configs/config.yaml

Page 22: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 22

Running Wraith

$ wraith capture config

Page 23: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 23

Wraith Responsive Gallery

Difference detected

Page 24: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io

320__dev.png 320__test.png 320__diff.png 320__data.txt

600__dev.png 600__test.png 600__diff.png 600__data.txt

24

Wraith Artifacts

wraith/shots/home

Each text file contains a number that represents the image difference.

Automated Checks

Page 25: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 25

Limiting Test Coverage

Static Header

DynamicContent Block

Page 26: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 26

Wraith CSS Selector Gallery

Page 27: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io

wraith

configs

config.yaml

component.yaml javascript

snap.js casper.js

shots

27

Wraith CSS Selectors with CasperJS

Casper Setup

$ wraith setup_casper

create configs/component.yaml create javascript/casper.js

Wraith Folder Structure

Separate configs for casper.js navigation.

Page 28: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 28

Wraith CSS Selector Configuration

browser: phantomjs: casperjs

snap_file: javascript/casper.js

paths: header: path: / selector: "header"

Edit configs/component.yaml Running it

$ wraith capture component

Page 29: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 29

Wraith CSS Selector Gallery

Page 30: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 30

Wraith History Mode

directory: shots

history_dir: shots_history

domains: test: http://test-panolopy-dreams.pantheon.io

Edit configs/config.yaml or configs/component.yaml

Capture and test with a single baseline image set.

Page 31: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 31

Wraith History Mode Commands

$ wraith history config

$ wraith latest config

Capture the Baseline

Compare the Baseline

Page 32: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 32

Wraith History Mode Gallery

Page 33: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 33

Wraith Summary

‣ Render with Webkit (Chrome) or Gecko (Firefox).

‣ Test two websites against each other (or a single baseline image set).

‣ Use selectors to limit coverage.

Page 34: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

FULL BROWSER TESTINGSelenium

Page 35: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 35

Selenium: Do it Yourself?

Page 36: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 36

Hosted Services

Page 37: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 37

WebdriverCSS

‣ Use Selenium for cross-browser testing

‣ Test directly in JavaScript with WebdriverIO

‣ Include and exclude capture regions with selectors.

Page 38: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 38

Limiting Test Coverage

Static Header

DynamicContent Block

Page 39: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 39

WebdriverCSS: Hide the Carousel

Page 40: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 40

WebdriverCSS: Exclude Regions

.webdrivercss('panolopy', { name: 'home', exclude: '#carousel' }, ...)

Page 41: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 41

Try Visual Regression Testing

‣ Prevent visual mistakes.

‣ Open source tools for a variety of setups.

‣ Cross-browser testing options with Selenium.

Page 42: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 42

Resources

‣ Headless Testing • https://github.com/BBC-News/wraith • http://casperjs.org/ • https://github.com/Huddle/PhantomCSS

‣ Full Browser Testing • http://www.seleniumhq.org/ • http://webdriver.io/ • https://github.com/webdriverio/webdrivercss • http://shoov.io/

Page 43: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

• Pantheon.io 43

Questions?

Images CC by SA 3.0 http://en.wikipedia.org/wiki/Eye_tracking#/media/File:Eye_tracking_thru_glass.JPG http://commons.wikimedia.org/wiki/File:Snellen_chart.svg

Page 44: ci for css Pantheon - DrupalCon · •Pantheon.io 2 CI FOR CSS Creating a Visual Regression Testing Workflow Presented by Kate Kligman May 13, 2015 • Pantheon.io 3

THANK YOU!To evaluate this session:losangeles2015.drupal.org/schedule