Web application and acceptance testing with selenium

Selenium is a great framework for testing the user interface of web applications. I’m very impressed by the simplicity of it and the yet powerful features it has.

In my opinion selenium is the missing piece in test driven development for web applications. Yeah I know HttpUnit, but with selenium there is no more need to reinvent functionality provided by the web UI. It also solves the problem with testing AJAX functionality on web pages.

I’ve personally used Selenium IDE and Selenium RC to do some testing with Firefox/Java/JUnit.

The only problem I have with the Selenium RC framework is that before I even can run a test I have to:

  1. start an application server
  2. start a selenium server

After the tests I also have to restart the deployment on the application server to get a clean environment to rerun the test.

My current solution to this problem is to get the application and selenium server up and running within a “unit” test. I developed a simple framework which can fire up an application server/servlet engine (Jetty, because it’s easier to embed than Tomcat) and a selenium server within a test, so I can easily deploy web applications for testing. After a test-class (or after each test-method) the application server deployment will be restarted/redeployed. I’ve tried to use JUnit 4 for implementing this, but the static @BeforeClass and @AfterClass methods were to inflexible for me.

So I’ve switched to TestNG which provides even more @Before… and @After… annotations to be even more flexible in setting these tests up.

If anybody is interested in this embedded server testing framework, I’ll ask my employer if I can share some code with you.

One Response

  1. Thanks for your kind words for Selenium! Yes, Selenium RC is a bit ‘expensive’ when it comes to the setup required compared to Selenium IDE, but the results you get are worth it. :-)

    I’m sure people would love to see the details of how you combined Selenium with TestNG in your build environment. If and when you can share your code, please send a note to the Selenium Users list (available at openqa.org). Thanks!

Leave a Reply