Selenium is a set of open source tools which you can use to set up automated tests for your web applications. The tools are quite simple to install and use, and are quite flexible (Fig 1). A great advantage of using an automated testing tool such as the ones provided by Selenium is that you can schedule the nightly testing of your web applications. The testing is triggered off automatically at a certain hour and you see the report in the morning.
01 Introducing Selenium IDE
Selenium IDE is an integrated development environment for running Selenium tests. It has been implemented as a Firefox extension, and has a recording feature which will maintain a list of user actions as they are performed and store them as a reusable script to play back. Selenium IDE also offers full editing of test cases for more precision and control. This tool has been advertised by the Selenium team as the easiest and the quickest way to get started with Selenium. One drawback, however, is that your testing is limited to Firefox. Although Firefox runs on all operating system platforms, it still has a long way to go to becoming the most popular web browser around. Testing your web application with Internet Explorer is still a necessity for a lot of developers. Selenium IDE does not allow you to do that.
02 Installing Selenium IDE
Installing Selenium IDE is quick and easy. All you need is to have a recent version of the Firefox web browser and an internet connection. Point Firefox here and add the Selenium IDE extension. Once it’s installed, you will need to restart your web browser to activate the Selenium IDE extension. Then you should be in business. Check to make sure that Selenium IDE is indeed installed. Go to Tools>Selenium IDE to check it out.
03 Quick tour of IDE settings
Although Selenium IDE is a pretty straightforward tool to use, there are a number of settings changes that you can make. To access these settings, you can click on the Preferences button in the Selenium IDE Add-On pane. This will launch a Preference pane for Selenium IDE. It has three tabs: General, Formats and Plugins. Tweak the settings here to make changes to the way Selenium IDE functions. For example, you can add or modify the format in which Selenium should expect information. It supports several different scripting languages including Perl, PHP and Ruby. Just be careful to make changes after understanding things.
04 Record your first script
There are a number of things that you can do using Selenium IDE. You can either record the moves you make on a website as a script, and have it played back or edit it and then play it, or you can write a script from scratch. Let’s look at how to record our steps on a website first. Pick a website and visit it with Firefox. Once you are at the website, launch Selenium IDE by going to Tools>Selenium IDE in the Firefox menu. The Selenium IDE pane will now launch. At the top right-hand side of the pane you will see a red button. This button is what you will need to use to record your script. Hit the button to begin recording. Now browse the page you want to test and perform the steps you need for this particular test. Once you are done, hit the red button again.
05 View the script
If you look at the Selenium IDE pane you will see that it has two tabs – Table and Source. These are for two editing modes: Table for graphical editing, and Source for textual editing of the script. In the Table view, the data is quite well organised for you to edit. At the top there’s a box that lists all the steps that were recorded by you. When you click on any of the steps, you see an expanded version of it below. This is where the command and the content are separated and presented to you for easy editing. You can also look at logs and other information in this view. The Source view is a bit cleaner. You have an editor and the logs. As the name suggests, you get to view the script in its source, and edit and save it.