We have a web application that we want to start running regression tests on, and one of the things I'm supposed to look for when choosing an alternative is a tool that has a recorder. However, I get the general feeling that it is frowned upon, and that writing tests in code is preferred. What are the eventual disadvantages or advantages of using a record and playback tool for regression testing?
I would not recommend record and play for regression testing for following reasons
- The tests would record un-necessary steps depending upon the level of recording present in tool. e.g In some applications selecting a combobox would be recorded as clicking it first and then selecting it. Sometimes it might be desirable sometimes not.
- The objects might get duplicated and unorganized making the test very difficult to maintain.
- Anyway to implement the logic and iterations you need to come down to code.
- You know what you are doing exactly when hand-coding the test.
I would say its like hand coding a website even though you have a WYSIWYG editor at your disposal. For learning and beginning with a tool and see its constructs you can use record and play but to make stable, maintainable and standard based tests you should hand code it taking help of record functionality if required.
The advantages would be
- Easy for beginners. Takes less time to get started.
- Faster test development (though eventually maintenance and debugging time would over-weigh this advantage)
- Cool to demo to your manager to persuade him to buy the licenses. :)
For web applications, most recorders translate clicks to XPath queries which are position based or CSS selectors which use only class names or ID attributes, so when the DOM structure changes, the tests have to be rewritten. This forces you to either rewrite the underlying code generated by the tool, or to assign ID attributes to every important element.