R – Automated GUI Testing: Meeting Us Halfway

automated-testsseleniumtestinguser interface

I've been tasked with developing a system for automated GUI testing and I could use some advice. As luck would have it, we are in the midst of a major redesign of our GUI and the developers doing the work are open to making their code more friendly to automation. My problem is that I'm not sure what to ask them to add. Whatever hooks are added can't impact the functionality, appearance or security of the interface and shouldn't have a noticeable impact on performance. Other than that, the sky's the limit!

The application in question is a web-based Java app accessed via AJAX. Most of the existing features are coded using jsp, Javascript and a little bit of Flash 8. The next wave of features will be done using the YUI Javascript library. I'm pretty much settled on Selenium as a test tool because of its flexibility and price tag (free). Major point: I'm aiming for test-reusability and ease-of-maintenance. My preference is to write code that detects, validates and exercises the page elements rather than use a record-and-playback system for test development.

Can anyone provide some guidance as to what hooks could be placed in the code or some best practices to make test development easier and the tests themselves more robust?

Best Answer

Basic guiding principle: if they want you to test something, testers need a way to get the application into that state, and once in that state, a way to validate that the state is correct.

So the first thing is to ensure they understand that automation is programming and the UI is your API.

  • Agreement to not arbitrarily change the UI -- if tester Bob see that the component changed from a button to a link, and it matches the spec, clicks and goes on. While a relatively easy code change in automation, it is a change that may have to be made in multiple locations. (your job as a tester is to understand that change happens and minimize the cost of maintenance; their job is to only make important changes and to understand the impact)

  • A way to determine which page you are on.... Bob can tell the difference between login and order entry, but how will automation know? If an enter field with the 'Username' label, the login page. If an entry field with Order number, the order field.

Not good -- better practice is a consistent UI element to identify the page -- page title, hidden component, etc.

  • A way to uniquely identify every element that you need to interact with (click, type in, verify, etc.) And not INPUT_42....

  • Ask the developers what information that testers can provide them to speed their debugging, and ask them to put it into a log file

  • Ability to dump state of the program

  • Consistent error handling & reporting (also just good UI design)

Related Topic