Home > Testing > Selenium - Web application testing system

Selenium - Web application testing system

When I have had the need for a testing system for web applications I have always used httpunit, which is very good and it has given me all the functionality that I’ve ever needed. A couple of weeks ago my boss hinted about Selenium, and as a developer with a lot of experience with web development it of course got me curious. I downloaded it and tried it out.

The first thing I noticed was that the GUI was pretty simple and straightforward, when Selenium is started from Firefox it assumes that the current page is the page that is should run its test cases on. If it is not, just change the “Base url” at the top of the GUI to the correct Url.  The recording is also started immediately and the user can start adding actions to the test case, this is done mainly by right-clicking on the web page and choosing from the different options, for example you can mark a portion of text and choose verifyTextPresent, after this the test action is shown the main window.

To run a test case or test suite, just click the recording button to stop recording and then on of the two play buttons.

There are two tabs, Table and Source, when clicking on the tab Source by default the source is shown as html, but as a Java programmer I would rather use JUnit to run Selenium test cases. Under Options -> Format it is possible to chose from a number of languages, as Java, C#, Perl and more. When a format other than html is chosen the “Table” tab is inactivated and also the run commands are inactivated. To use the generated code, in my case Java code, first the proper JUnit packages must be in the projects classpath. I use Eclipse so I just add the junit.jar to my Java Build Path. Then the Selenium packages. Then finally before executing the class that extends SeleneseTestCase the selenium server must be started. I didn’t need to configure anything to make the server work, just started it from my terminal, very good!

When running the test case or test suite Selenium opens firefox, very disappointing but it is not hard to see why they went this route. Httpunit has all the parsers and connectors it need to take care of the http requests and responses, selenium seems to piggy back on Firefox. This is not disaster, but it is slow. Selenium has to fire up firefox as a new process then run the test cases in a local web page with frames. After the test case or suite has been executed the results are reported in Junit as expected.

Overall Selenium works quite nice although slow when using it with Junit, and I was able to simulate user login and other user behaviour and assert the outcome with it, both from the GUI and from Junit.

Frank Lindholm Testing

  1. No comments yet.
  1. No trackbacks yet.
Security Code: