SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Visual Testing
Using PhantomCss
Vishnu Narang
@vishnu_narang
Shridhar Deshmukh
@_shree33
Why did we use it?
What was our use case?
Our use case.
● We are on a project, working on a multi-national,
multi locale marketing website. Each page of the
website is made up of modules. Each module can be
used on many pages with different content.
● Recently, we got a unique requirement. We needed to
go live in middle-east countries for which we needed
to support Right-to-Left (RTL) languages like Arabic.
Our use case. ..cont
● Not only does the content flow from right to left,
even the layout and the interactions needed to flow
from right to left.
● Obviously, we needed to change lots of CSS/HTML in
our common code to support this.
While implementing this, we realised one thing...
breaking CSS is easy, testing it is hard.
Breaking css is easy, testing it is hard...
● Every time you make a change in common css code for a
website, you always have the possibility that something else
breaks on some other page.
● In our case, changing css for RTL for some module sometimes
broke it’s LTR variation on some pages.
● We had to plan a CSS testing strategy.
CSS testing options..
● Jasmine:
We used jasmine for our javascript tests. But nothing stopped us from using it for CSS
“Unit” tests.
We would only test the following for elements:
○ Is it floated Left or Right
eg: expect($el).toHaveCss({float: right});
○ Does it have Left: auto or greater than zero.
eg: expect($el).toHaveCss({left: auto});
○ Is it on the left or right of another element.
eg: expect(rightElOffset).toBeGreaterThan(leftElOffset); right Element
(rightEl)
left Element
(leftEl)
$el(left: auto)
$el
What is PhantomCss?
● Tool for Automated Visual Testing.
● Used for Web Apps, Live style guides and
responsive layouts.
How it works?
● PhantomJs for headless webkit.
● CasperJs for screenshots.
● ResembleJs for image comparison.
Example
padding: 11px 19px; padding: 11px 20px;
Installation (based on Mac OS)
npm install phantomjs
...And start visual regression testing
git clone https://github.com/Huddle/PhantomCSS.git
brew install casperjs
● Layout related issues.
Demo
Demo
● Layout related issues.
● Selector based tests.
● Layout related issues.
● Selector based tests.
● Action based tests.
Demo
Best Practices
● Name your screenshots carefully
● Use same OS/Browser for both runs
● Test only when you need
● Don’t always take fullpage screenshots
When not to use it?
● Right at the start of your project when the
pages keep changing.
● On a small project with very few pages.
● When you have a better tool to do your
job.
Advanced Features
● Making it deterministic using network
monitoring and wait time. (github.gist)
● Parallel execution using multi-threading
(sbt) + PhantomCss
References & Resources
● Official Repo: https://github.com/Huddle/PhantomCSS
● Our Modified version:
https://github.com/vishnun/visual_testing_using_phantomcss
● github gist for network monitoring:
https://gist.github.com/vishnun/23c66b0bc6b6194cf5cc
● More tools and wrappers:
grunt-phantomcss, PhantomXHR, PhantomFlow and grunt-
phantomflow.
THANKS
Youtube Video of this talk.

Contenu connexe

En vedette (8)

TDC 2014 SP - Visual Regression Testing com PhantomCSS
TDC 2014 SP - Visual Regression Testing com PhantomCSSTDC 2014 SP - Visual Regression Testing com PhantomCSS
TDC 2014 SP - Visual Regression Testing com PhantomCSS
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Kavya Prasad_Resume
Kavya Prasad_ResumeKavya Prasad_Resume
Kavya Prasad_Resume
 
PradeepKumar_Tableau Developer
PradeepKumar_Tableau DeveloperPradeepKumar_Tableau Developer
PradeepKumar_Tableau Developer
 
Naveen QlikView Developer
Naveen QlikView DeveloperNaveen QlikView Developer
Naveen QlikView Developer
 
Jagannath cv
Jagannath cvJagannath cv
Jagannath cv
 
Resume_Ganesh_updated
Resume_Ganesh_updatedResume_Ganesh_updated
Resume_Ganesh_updated
 
RESUME_TEJA
RESUME_TEJARESUME_TEJA
RESUME_TEJA
 

Similaire à Visual testing using PhantomCss

Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...
Atos_Worldline
 
Responsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJSResponsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJS
Christian Heilmann
 

Similaire à Visual testing using PhantomCss (20)

"Crafting a Third-Party Banking Library with Web Components and React", Germa...
"Crafting a Third-Party Banking Library with Web Components and React", Germa..."Crafting a Third-Party Banking Library with Web Components and React", Germa...
"Crafting a Third-Party Banking Library with Web Components and React", Germa...
 
Web Development: Making it the right way
Web Development: Making it the right wayWeb Development: Making it the right way
Web Development: Making it the right way
 
Hybrid Application Development
Hybrid Application DevelopmentHybrid Application Development
Hybrid Application Development
 
Web II - 01 - Introduction to server-side development
Web II - 01 - Introduction to server-side developmentWeb II - 01 - Introduction to server-side development
Web II - 01 - Introduction to server-side development
 
Use React tools for better Angular apps
Use React tools for better Angular appsUse React tools for better Angular apps
Use React tools for better Angular apps
 
Xlab #2: wzorce projektowe
Xlab #2: wzorce projektoweXlab #2: wzorce projektowe
Xlab #2: wzorce projektowe
 
Intro to Flutter
Intro to FlutterIntro to Flutter
Intro to Flutter
 
React Workshop
React WorkshopReact Workshop
React Workshop
 
Html 5 mobile - nitty gritty
Html 5 mobile - nitty grittyHtml 5 mobile - nitty gritty
Html 5 mobile - nitty gritty
 
Javascript
JavascriptJavascript
Javascript
 
Quo vadis, JavaScript? Devday.pl keynote
Quo vadis, JavaScript? Devday.pl keynoteQuo vadis, JavaScript? Devday.pl keynote
Quo vadis, JavaScript? Devday.pl keynote
 
Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...
 
Skill Session - Web Multi Device
Skill Session - Web Multi DeviceSkill Session - Web Multi Device
Skill Session - Web Multi Device
 
GWT Reloaded
GWT ReloadedGWT Reloaded
GWT Reloaded
 
Six reasons to learn JavaScript
Six reasons to learn JavaScriptSix reasons to learn JavaScript
Six reasons to learn JavaScript
 
Beyond the Standards
Beyond the StandardsBeyond the Standards
Beyond the Standards
 
Js basics
Js basicsJs basics
Js basics
 
Angular Vienna - Use React tools for better Angular apps
Angular Vienna - Use React tools for better Angular appsAngular Vienna - Use React tools for better Angular apps
Angular Vienna - Use React tools for better Angular apps
 
Responsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJSResponsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJS
 
Testing Angular 2 Applications - Rich Web 2016
Testing Angular 2 Applications - Rich Web 2016Testing Angular 2 Applications - Rich Web 2016
Testing Angular 2 Applications - Rich Web 2016
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Visual testing using PhantomCss

  • 1. Visual Testing Using PhantomCss Vishnu Narang @vishnu_narang Shridhar Deshmukh @_shree33
  • 2. Why did we use it? What was our use case?
  • 3. Our use case. ● We are on a project, working on a multi-national, multi locale marketing website. Each page of the website is made up of modules. Each module can be used on many pages with different content. ● Recently, we got a unique requirement. We needed to go live in middle-east countries for which we needed to support Right-to-Left (RTL) languages like Arabic.
  • 4. Our use case. ..cont ● Not only does the content flow from right to left, even the layout and the interactions needed to flow from right to left. ● Obviously, we needed to change lots of CSS/HTML in our common code to support this. While implementing this, we realised one thing...
  • 5. breaking CSS is easy, testing it is hard.
  • 6. Breaking css is easy, testing it is hard... ● Every time you make a change in common css code for a website, you always have the possibility that something else breaks on some other page. ● In our case, changing css for RTL for some module sometimes broke it’s LTR variation on some pages. ● We had to plan a CSS testing strategy.
  • 7. CSS testing options.. ● Jasmine: We used jasmine for our javascript tests. But nothing stopped us from using it for CSS “Unit” tests. We would only test the following for elements: ○ Is it floated Left or Right eg: expect($el).toHaveCss({float: right}); ○ Does it have Left: auto or greater than zero. eg: expect($el).toHaveCss({left: auto}); ○ Is it on the left or right of another element. eg: expect(rightElOffset).toBeGreaterThan(leftElOffset); right Element (rightEl) left Element (leftEl) $el(left: auto) $el
  • 8. What is PhantomCss? ● Tool for Automated Visual Testing. ● Used for Web Apps, Live style guides and responsive layouts.
  • 9. How it works? ● PhantomJs for headless webkit. ● CasperJs for screenshots. ● ResembleJs for image comparison.
  • 10. Example padding: 11px 19px; padding: 11px 20px;
  • 11. Installation (based on Mac OS) npm install phantomjs ...And start visual regression testing git clone https://github.com/Huddle/PhantomCSS.git brew install casperjs
  • 12. ● Layout related issues. Demo
  • 13. Demo ● Layout related issues. ● Selector based tests.
  • 14. ● Layout related issues. ● Selector based tests. ● Action based tests. Demo
  • 15. Best Practices ● Name your screenshots carefully ● Use same OS/Browser for both runs ● Test only when you need ● Don’t always take fullpage screenshots
  • 16. When not to use it? ● Right at the start of your project when the pages keep changing. ● On a small project with very few pages. ● When you have a better tool to do your job.
  • 17. Advanced Features ● Making it deterministic using network monitoring and wait time. (github.gist) ● Parallel execution using multi-threading (sbt) + PhantomCss
  • 18.
  • 19. References & Resources ● Official Repo: https://github.com/Huddle/PhantomCSS ● Our Modified version: https://github.com/vishnun/visual_testing_using_phantomcss ● github gist for network monitoring: https://gist.github.com/vishnun/23c66b0bc6b6194cf5cc ● More tools and wrappers: grunt-phantomcss, PhantomXHR, PhantomFlow and grunt- phantomflow.

Notes de l'éditeur

  1. Talk about the two things to test: Unit tests using Jasmine and Regression testing using screenshot comparison.
  2. PhantomCss is command line tools that can be used to automate the visual regression testing. In this process PhantomCss visits the specified web pages and take snapshots of them, may be at different viewport sizes. And then It compares these images with your baseline images that were taken before you made any changes in CSS. The images are compared pixel by pixel to determine if their is any difference between baseline image and newly taken image. For failed comparison PhantomCss creates comparison image which highlights the portion of images which actually got changed in newer snapshot. You can use PhantomCss to test your web app, if you are making any major refactoring around your css. You can also use PhantomCss to make sure that the change that you made for desktop breakpoint is not breaking mobile or tablet layout. With phantomCss you compare whole page with another page, and you can also compare part/section of page.
  3. PhantomCss is a combination of 3 different tools Phantom Js - is a headless webkit browser that allows you to render web pages Casper Js - A Navigation and scripting tool that allows you to interact with the page rendered by phantomJs Resembe Js - compares two images pixel by pixel and determine the differences between them