visual css-regression-testing-with-phantom css

24
Visual/CSS Regression Testing MidCamp 2015 University of Illinois at Chicago Saturday, March 21, 2015 Catching the “Unintended Consequences” of modifying your theme

Upload: lisa-ridley

Post on 16-Jul-2015

1.041 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Visual css-regression-testing-with-phantom css

Visual/CSS Regression Testing

MidCamp 2015 University of Illinois at Chicago

Saturday, March 21, 2015

Catching the “Unintended Consequences” of modifying your theme

Page 2: Visual css-regression-testing-with-phantom css

Who am I?• Lisa Ridley • Solutions Architect, Promet Source • [email protected] • drupal: lhridley • twitter: lhridley • blog: codementality.com

Page 3: Visual css-regression-testing-with-phantom css

About Promet Source

Custom Development

• Drupal websites • Drupal-based web applications

• Mobile apps integration • Systems integration • CMS migrations • Custom ecommerce • Prototyping and proof-of-concepts

Support

• 24x7 with SLA • Support for Drupal sites built by others

• 24x7 monitoring • Drupal security and maintenance updates

• QA for custom modules • Code-level fixes • Help desk support • Ongoing development

DevOps

• Automated cloud infrastructure

• Drupal deployments • Configuration management for Drupal

• Automated testing • Continuous integration • Performance and scaling • Open source tools (Chef, Git, Jenkins)

Open Source Applications – Focus on Drupal

➢ Founded in 2003 ➢ Open source technologists ➢ Drupal platform since 2008 ➢ Mobile apps since 2009

➢ Based in Chicago ➢ Distributed global team ➢ Agile development practices ➢ 24x7 support

Page 4: Visual css-regression-testing-with-phantom css

–Wikipedia

What is Regression Testing?

Page 5: Visual css-regression-testing-with-phantom css

How do you regression test the

visual components of a user interface?

Page 6: Visual css-regression-testing-with-phantom css

What if you could take a “before” and “after”

picture?

And could easily compare those pictures

to each other?

Page 7: Visual css-regression-testing-with-phantom css

Enter PhantomCSS

Page 8: Visual css-regression-testing-with-phantom css

How does it work?

Page 9: Visual css-regression-testing-with-phantom css

What does that look like?

Baseline Image Comparison Image

PhantomCSS Diff Image

Page 10: Visual css-regression-testing-with-phantom css

PhantomCSS Dependencies

+

PhantomJS (v1.9.7)

CasperJS (1.1.beta-3)

SlimerJS (v0.9.4)

Page 11: Visual css-regression-testing-with-phantom css

Other Dependencies for Testing Servers (Linux)

• FontConfig • FreeType • ttf-dejavu • ttf-mscorefonts-installer • xvfb (SlimerJS)

Page 12: Visual css-regression-testing-with-phantom css

Skillsets Needed to Write Tests for PhantomCSS

Javascript

Page 13: Visual css-regression-testing-with-phantom css

casper.start( ‘url-of-web-page’ ); casper.viewport(1024, 768);

casper.then(function(){phantomcss.screenshot(‘#css-selector‘, ‘image-name’);

});

casper.then( function now_check_the_screenshots(){ phantomcss.compareAll(); });casper.then( function end_it(){ casper.test.done(); });casper.run(function(){ phantom.exit(phantomcss.getExitStatus()); });

Page 14: Visual css-regression-testing-with-phantom css

Javascript Object Instances Available to Test Scripts

• phantom • casper • phantomcss

Page 15: Visual css-regression-testing-with-phantom css

Author recommended Best Practices for PhantomCSS

• Does not replace functional testing • Don’t use complex CSS3 selectors • Name Your Screenshots • Don’t try to test all the visuals • Full page screenshots are a bad idea

Page 16: Visual css-regression-testing-with-phantom css

Limitations of PhantomCSS• No Support for Flash • May require non-standard font installations on your

testing server • May generate false test failures due to spatial

aliasing of antialiased images • Some page elements that have display: none on

larger viewports but are visible on smaller viewports are seen as “not visible”

Page 17: Visual css-regression-testing-with-phantom css

Let’s look at a test site

Page 18: Visual css-regression-testing-with-phantom css

Fixed Header and Nav BarNav bar Items are Mega Menus

Front Page Slider

Pre Content BlocksBlocks have mouseover color

change on background

Two column content area

Fixed Footer

Page 19: Visual css-regression-testing-with-phantom css

Test Suite for Test Site• Homepage • Homepage with each

Megamenu displayed • Each Megamenu

element • Header, Nav bar,

footer

• Pre-content blocks • Pre-content blocks

with each in “hover” state

• Content areas (left and right)

20 images in all

Page 20: Visual css-regression-testing-with-phantom css

Let’s switch to the actual site and run a demo

Page 21: Visual css-regression-testing-with-phantom css

Questions?

Page 22: Visual css-regression-testing-with-phantom css

Documentation• casperjs.readthedocs.org

- casperjs.readthedocs.org/en/latest/selectors.html

- casperjs.readthedocs.org/en/latest/modules/casper.html

- casperjs.readthedocs.org/en/latest/modules/mouse.html

- casperjs.readthedocs.org/en/latest/modules/utils.html • phantomjs.org/documentation/ • github.com/Huddle/PhantomCSS/blob/master/

README.md

Page 23: Visual css-regression-testing-with-phantom css

• Lisa Ridley • Solutions Architect, Promet Source • [email protected] • drupal: lhridley • twitter: lhridley • blog: codementality.com

Who am I?

Page 24: Visual css-regression-testing-with-phantom css

Thanks for coming!