Simple walkthrough testcase using SeleniumTestCase

After all the preparations its time to write some tests. Imagine a sample-application that contains a page per component from a component set. For our nightly build we want to know whether all pages work. So a first test would be to use the browser and click through all pages. Annoying and always the same. Calls for an automated test, doesn’t it?

@Test public void checkCatalog() {
  assertPageTitleEquals("JSF Components Catalog");
  clickAndWait("link=Layout components");
  assertPageTitleEquals("Layout components");
  assertPageTitleEquals("Layout Component");
  assertPageTitleEquals("Container Configurator");
  assertPageTitleEquals("GroupBox Component");
  clickAndWait("link=Tabbed Pane");
  assertPageTitleEquals("TabbedPane Component");
  assertPageTitleEquals("MessagesArea Component");

Looks easy, doesn’t it? Looks and feels just like the instructions for a human tester. And that’s the writing test should be: simple.

Such a test can also survive a revamp of the menu-structure of the application, as long as the texts of the menu-items remain constant, the testcase, just like the human tester, still find the links to click on. Was very usefull when we did such a refactoring of the sample-application. Every now and then someone from teh team would do the “cvs update”-redeploy-“let the testuite run”-cycle and just report which areas needed some massaging.

2 Comments on “Simple walkthrough testcase using SeleniumTestCase”

  1. mjdenham says:

    Your articles on writing JUnit tests with Selenium are very helpful.

    Is it possible to download the Selenium test code that is mentioned in your articles?



  2. ajesse says:

    Do you mean the Selenium Framework, or a complete testcase (a complete java-class as opposed to the excerpts)?

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s