KEMBAR78
CIRCUIT 2015 - Glimpse of perceptual diff | PDF
CIRCUIT – An Adobe Developer Event
Presented by ICF Interactive
Glimpse of
Perceptual Diff
Rachel Ingles
Different names
Perceptual	
  
Diff	
  
User	
  
Interface	
  
Tes4ng	
  
CSS	
  
Regression	
  
Tes4ng	
  
Visual	
  
Regression	
  
Tes4ng	
  
Visual comparison
Stable	
   New	
  Release	
  
x
x
x
Image	
  from	
  scalingengineeringfordigital.files.wordpress.com	
  
Site1: (Sample production)
Sample	
  site	
  from	
  Michael	
  Gilbert	
  
Site 2: New Release
Spot the difference
Resemble.js (http://huddle.github.io/Resemble.js/)
Different	
  Same	
  
Compare	
  
Analyze	
  
Image	
  
Interactive Site: Using sample images
Interactive Site: Other options
Interactive Site: Using Site1 and Site2
Resemble.js: Code snippet
resemble(file).compareTo(file2).onComplete
(function(data){	
  
	
  return	
  data;	
  
	
  /*	
  
	
  {	
  
	
  	
  	
  misMatchPercentage	
  :	
  100,	
  //	
  %	
  
	
  	
  	
  isSameDimensions:	
  true,	
  //	
  or	
  false	
  
	
  	
  	
  getImageDataUrl:	
  function(){}	
  
	
  }	
  
	
  */	
  
});	
  
Other tools
Takes	
  screenshots	
  
Compares	
  images	
  
Generates	
  	
  
reports	
  
Images	
  from	
  cliparts.co	
  
Other tools
CSS Critic (https://github.com/cburgmer/csscritic)
•  Lightweight
tool for CSS
CSS Critic: Setup
•  npm	
  install	
  csscritic	
  
CSS Critic: Setup
•  Create	
  RegressionRunner.html	
  file	
  
•  Register	
  page/s	
  under	
  test	
  
	
  
csscritic.add({	
  
	
  	
  	
  	
  url:	
  'SOME_URL',	
  	
  	
  	
  	
  //	
  link	
  to	
  the	
  test	
  case	
  HTML	
  document	
  
	
  	
  	
  	
  //	
  Optionally:	
  
	
  	
  	
  	
  desc:	
  'some	
  text',	
  	
  	
  //	
  a	
  description	
  of	
  the	
  test	
  case	
  
	
  	
  	
  	
  width:	
  number,	
  	
  	
  	
  	
  	
  	
  //	
  the	
  viewport	
  width	
  in	
  pixel	
  
	
  	
  	
  	
  height:	
  number,	
  	
  	
  	
  	
  	
  //	
  the	
  viewport	
  height	
  in	
  pixel	
  
…	
  
});	
  
Initial Load: Need baseline
Accepted baseline
Differences found
CSS Critic: Limitations
•  Firefox and Chrome only
•  Same origin restrictions
Dpxdt (https://github.com/bslatkin/dpxdt)
workers	
  
Dpxdt: YAML configuration
setup:	
  |	
  
	
  	
  	
  	
  python	
  -­‐m	
  SimpleHTTPServer	
  
	
  
waitFor:	
  
	
  	
  	
  	
  url:	
  http://localhost/Site1/www/index.html	
  
	
  	
  	
  	
  timeout_secs:	
  5	
  
	
  
tests:	
  
	
  	
  -­‐	
  name:	
  demo	
  
	
  	
  	
  	
  url:	
  http://localhost/Site1/www/index.html	
  
	
  	
  	
  	
  config:	
  
	
  	
  	
  	
  	
  	
  	
  	
  viewportSize:	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  width:	
  800	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  height:	
  600	
  
	
  	
  	
  	
  	
  	
  	
  	
  injectCss:	
  |	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  body	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  background-­‐color:	
  white;	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
Local Dpxdt: Modes
dpxdt	
  [update|test]	
  [test_directory]	
  
•  update
Image	
  from	
  cliparts.co	
  
Baseline	
  
Compare	
  
?	
  
Local Dpxdt: Modes
dpxdt	
  [update|test]	
  [test_directory]	
  
•  test
Images	
  from	
  cliparts.co	
  
Baseline	
  
Compare	
  
Dpxtd: Server Approach
•  Python virtual directory
Dpxtd: Server Approach options
•  Site Diff
•  Pair Diff
•  Diff My Images
•  Diff My URLs
Dpxtd: Site Diff
Main	
  
Page1	
  
Page3	
  
Page4	
  
Page2	
   Page5	
  
Dpxtd: Pair Diff
Site	
  1	
   Site2	
  
Img1	
  
Img2	
  
Img3	
  
Img1	
  
Img2	
  
Dpxtd: Diff My Images
Before	
  
Img3	
  
Img2	
  
Img1	
  
AMer	
  
Img3	
  
Img2	
  
Img1	
  
Dpxtd: Diff My URLs
Before	
  
URL3	
  
URL2	
  
URL1	
  
AMer	
  
URL3	
  
URL2	
  
URL1	
  
EXAMPLE: Pair Diff
./run_url_pair_diff.sh	
  [build	
  num]	
  [site1]	
  [site2]	
  
EXAMPLE: Pair Diff
 	
   	
  	
   	
  	
   	
  	
  
Summary
Images	
  from	
  cliparts.co	
  
Selenium	
  
PhantomJS	
  
ResembleJS	
  
ImageMagick	
  
CSSCri4c	
  
Dpxtd	
  
PhantomCSS	
  
Wraith	
  
Applitools	
  
Capture	
   Compare	
   Report	
   Perceptual	
  
Diff	
  
References
•  Responsive Started Kit Pro - https://github.com/
mpgilbertusa/Responsive-Starter-Kit-Pro
•  Resemble.js – http://huddle.github.io/Resemble.js/
•  CSS Critic - https://github.com/cburgmer/csscritic
•  Dpxdt - https://github.com/bslatkin/dpxdt
Rachel Ingles
Test Automation Developer
ICF Interactive
rachel.ingles@icfi.com

CIRCUIT 2015 - Glimpse of perceptual diff