Chapter 8. Tutorial: Starting to Test Web Applications

Table of Contents

8.1. Creating a Test Suite
8.1.1. Choosing a Name
8.1.2. Selecting a Toolkit
8.1.3. Choosing a Scripting Language
8.2. Recording a Test
8.2.1. Creating a Test Case
8.2.2. Recording User Input
8.2.3. A Generated Script
8.3. Introducing Verification Points
8.3.1. Choosing a Location for the Verification Point
8.3.2. Selecting Properties to Check
8.3.3. Injecting a Verification Point Into the Script
8.3.4. Verification Points in Action
8.4. Making the Test More Robust
8.4.1. Factors Influencing Robustness
8.4.2. Coping With Timing Differences
8.4.3. Handling Different Page States
8.5. Conclusion

This chapter will use the Squish IDE to create, run, and extend a test of a sample web application. We will use the web interface of the W3C Markup Validation Service to demonstrate how Squish is used to test web applications.

Even though we will use the Squish IDE, a graphical front end to the Squish testing framework, anything we will do can also be accomplished using command line tools which is interesting when thinking about automating your tests (doing nightly runs of your regression test suite, for example). Whenever we describe how to do something using the Squish IDE we will also show how to do it with the command line tools. For full details on Squish's command line tools, please refer to the Reference Manual (Chapter 16).

[Tip]Tip

The complete test suite we create in this tutorial is available in squish/examples/web/suite_validator_js, so you don't necessarily have to type everything shown here yourself.

For testing applications with Squish, a special server application called squishserver must be running (for further information, you might want to have a look at the section Squish Concepts and Making an Application Testable (Chapter 4)). If you use the Squish IDE, you don't need to worry about this since the Squish IDE will start a server automatically and care about everything. However, not using the Squish IDE means that you have to start squishserver manually before you can record or run any tests. Please see the respective section in the command line reference squishserver (Section 16.5.2) for information how to do this.

[Note]Note

Due to a technical limitation in Konqueror, it is not possible to test websites running on a different host than localhost in Konqueror.

So if you need to access web pages which are not located on the local machine you can circumvent this problem by forwarding the remote port of the webserver to localhost. You can use e.g. ssh to forward the connection. If you want to test, e.g. www.google.com you can forward it by

ssh -L 8080:www.google.com:80 localhost

Now simply direct Squish to use http://localhost:8080 instead of http://www.google.com and you should be able to test it just fine.