5.6. Automating the UI Using Record and Playback

So far in this chapter, you've learned about creating UI tests by hand, meaning that each behavior is coded by hand. This next section will discuss the Record and Playback model, where a tool is used to record the steps and let an application play back performing test cases on each page being played back.

5.6.1. Recorded Tests

Tests that are recorded are the most brittle and many developers don't like to work with them because they are so fragile. Many scripts follow the same pattern: navigate to a page, poke some buttons, and then look at the results. UI tests can be hard to work with because of a lack of clarity. You start with a small script and you keep adding to it. Code in the middle of the script may depend on code that happens in the beginning, and there is seldom an indication for why a keystroke is happening. Most test recorders don't follow the 'Don't repeat yourself' (DRY) principle and duplicate logic from test to test instead. When working with an application that has no UI tests created, using a test recorder can save a great deal of time. It can be very overwhelming to try to create handwritten UI tests for an application that has only 10 web pages, let alone hundreds. We have discussed the negatives of recording tools, but some tools available create scripts that are very easy to use and do not include unneeded code. Well-written test recorders are also great to help a developer new to the UI testing tool learn ...

Get Testing ASP.NET Web Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.