Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automated testing of CSS and HTML front-end coding

Tags:

I'm a front-end developer coding CSS, HTML and Javascript (in that order) and most of the work I do is design-lead. Whilst the quality of the designs I create with CSS is subjective, much of the coding is purely functional / layout and I am interested in any way to automate the testing of my page.

My question can be split into two parts

  1. Does anyone have any existing techniques or suggestions for automatically testing CSS or HTML, particularly with regard cross-browser compatibility?

  2. As CSS can be roughly divided into properties that control layout and those that control design, is automated testing only viable for layout (it can't be possible to automatically and valuably test that a colour is correct, for example)? If so, what sort of CSS values might be suitable for boolean acceptance tests?

Here are my initial examples of boolean layout values that could be tested - there must be others?

  • Does a pop-up appear above other content (z-index)
  • Does a footer clear all other content (float)

Thanks for your help. Part three of the question is of course "Am I wasting my time going down this route?".

***** edit *****

I have found this article that asks the same questions I've asked, but more in depth and perhaps a little more eloquently.

http://www.morethanseven.net/2008/10/13/unit-testing-css-looking-solution/

Moving forward I am trying to isolate some examples from my work where CSS alone has caused functional errors however those that I've found so far are bugs with JS and CSS combined. I would still like to automatically test these sorts of errors, but appreciate that with javascript used it is beyond the scope of my original question.

***** edit 2 *****

I've since blogged about how I set about solving this problem, available here:

http://blog.ajcw.com/2010/12/automated-css-testing-or-how-one-css-coder-is-now-responsible-for-breaking-%E2%80%93-and-fixing-%E2%80%93-the-build/

like image 685
ajcw Avatar asked Oct 28 '10 14:10

ajcw


People also ask

Can you automate front-end testing?

Front-end testing helps ensure that the core functionalities of a web or desktop application work properly and appear correctly to the end-user. By automating front-end testing, teams can release new features and updates faster and with fewer bugs.

Which method of CSS is best for testing?

Which Method of CSS is Best for Testing. Automatic CSS testing is the most reliable way of detecting breaking changes after a CMS update, or after updating plug-ins and themes.


1 Answers

Have a look into Selenium - it's a browser-based automated testing tool. I think it's what you're looking for.

It works with all browsers (it has an IDE in Firefox for creating your test scripts, but the scripts themselves can be run in any browser)

It allows you to test the contents of the DOM, etc against the expected output at any point during the script.

like image 67
Spudley Avatar answered Nov 30 '22 18:11

Spudley