css-awesome

Automation-Test Some CSS Like A Boss

CSS is what makes a website pretty. However it does so only when well written and properly designed. Tests are necessary to make sure everything is working well and users see what they are supposed to rather than text crawling outside its frames and many more awful pieces of a little personal hell for perfectionists.

And, despite all the benefits you may gain from manual testing this path is still not the best option sometimes. Automation will be required and you surely want to know how things are done before bursting into that world with a blazing sword and desire for perfection.

Why automate?

Manual testing has many advantages and certainly deserves a place somewhere in the project. More to that point: it should be done! However repeated manual testing may be a simple waste of time, effort and resources especially if we are talking about responsive pages and the necessity to test every single layout.

There are several other solid points. When was the last time you have seen the CSS code on a large project? It’s more than huge, the thing is enormous and looks ready to blow because of any careless twig here or there. If you rely on manual means only you will have to go through all nine circles of hell while Refactoring. However Automation will make this process almost painless.

There is also Regression that may be hard to be identified precisely due various factors like defects popping out in areas that are not situated anywhere around active development or even design apathy. If your CSS testing session is automated you will find less trouble on your way to new discoveries in Regression.

However not all automation is valid. Take the XPath for example or any CSS selector. Making sure that any .green-button is existing does not equal making sure it is a button and that it’s actually green.

There is more than one way to skin a cat!

Basically there are two nice ways of automating CSS tests:

  • Screenshot comparison
  • Usage of window.getComputedStyle() for assertion of some computed styles with JS

Surely both these ways have series of strong sides as well as downfalls. My personal favorite is the first one, although I’m pretty eager to read all ideas you may have in the comment section. But before that I would have no notice why I enjoy screenshot comparison more. This way you are testing the exact pieces of the website your users will be seeing.

Some nice tools here would be:

  • Needle
  • Wraith is great yet it compares two websites when testing. May be in handy within several interesting projects.

TestFort Blog

About TestFort Blog

TestFort blog is an official blog of TestFort QA Lab company and is dedicated to various QA and software testing issues.


no comments yet

Be the first to comment this post!

Would you like to share your thoughts?

Software testing & QA blog by TestFort © 2017

×