Interface Unit Tests with Selenium


this week started with tests development, since I took the responsability of testing a Web Application. However, different from the others tests that I’ve done in the past, which covered C# code,  this ones are related to the project’s user interface. So, testing javascript code and interface functionality are now part of my work. Due to that, I found and amazing IDE with this puporse: let me show you Selenium.

“Selenium IDE is a Firefox addon that records clicks, typing, and other actions to make a test, which you can play back in the browser. Selenium IDE is not only recording tool: it is a complete IDE. You can choose to use its recording capability, or you may edit your scripts by hand”.

Here, is some of its features:

  • Easy record and playback
  • Intelligent field selection will use IDs, names, or XPath as needed
  • Autocomplete for all common Selenium commands
  • Walk through tests
  • Debug and set breakpoints
  • Save tests as HTML, Ruby scripts, Java, C# or any other format
  • Option to automatically assert the title of every page

All you have to do is to recorde yourself a test by doing some actions with your mouse and keyboard in a web page, and later reproduce the test as if you were doing the working again. With that, is possible to test almost everything you want to check in a html code, which means, in the interface of the web page.

Let’s do an easy example. First of all, install the firefox extension here. After restarting your firefox, let’s navigate to the google home page and open the Selenium IDE by clicking on Tools -> Selenium IDE. Remember to press the recorde button, as show in the picture below, to start recording the test.

Now, type “Talking about computer science” and press OK. Later, click on the first occurency of the search, redirecting you to my blog 🙂

Now, select “nandokakimoto” and with the rigth button choose “verifyTextPresent nandokakimoto”, which means that the test will look for this text when it runs.

It’s done! Now stop the test by clicking again on the record button in Selenium IDE. Take a  look at the set of commands shown in the table to verify if the are correct. Then, it’s time to run the test and see the result. So, click on the run icon, as show in the picture below, and you will see that the test run with success.

To see the test code in C#, Ruby or Java code, just click on Options -> Format and choose your prefered language. It’s really easy. Now, go forward and create your own interface tests.

See you,


2 thoughts on “Interface Unit Tests with Selenium

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