Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language. Selenium provides a test domain specific language (DSL) to write tests in a number of popular programming languages, including Java, Ruby, Groovy, Python, PHP, and Perl. Test playback is in most modern web browsers. Selenium deploys on Windows, Linux, and Macintosh platforms.
Selenium was developed by a team of programmers and testers at ThoughtWorks. It is open source software, released under the Apache 2.0 license and can be downloaded and used without charge. The latest side project is Selenium Grid, which provides a hub allowing the running of multiple Selenium tests concurrently on any number of local or remote systems, thus minimizing test execution time.
This tool is primarily developed in Java Script and browser technologies and hence supports all the major browsers on all the platforms. For example, you can have your automation scripts written for Firefox on Windows and run them on Firefox in Mac. Most of the time, you will not need to change your scripts for them to work on Mac. In terms of coverage for platform and browser, Selenium is probably one of the best tool available in the market for web applications. There are three variants of Selenium, which can be used in isolation or in combination to create complete automation suite for your web applications.
* Selenium IDE
* Selenium Core
* Selenium Remote Control
In this article, we will discuss Selenium IDE. Subsequent articles in the series will cover Selenium Remote Control and Selenium Core as well.
Advantage/Usages of Selenium IDE
Selenium IDE is the easiest way to use Selenium and most of the time it also serves as a starting point for your automation. Selenium IDE comes as an extension to the Firefox web browser. This can be installed from either openqa or mozilla distribution site. Selenium extension will be downloaded as XPI file. If you open this file using File -> open in Mozilla, it should get installed.
Biggest drawback of Selenium IDE is its limitation in terms of browser support. Though Selenium scripts can be used for most of the browser and operating system, Scripts written using Selenium IDE can be used for only Firefox browser if it is not used with Selenium RC or Selenium Core.
Selenium IDE is the only flavor of Selenium which allows you to record user action on browser window. It can also record user actions in most of the popular languages like Java, C#, Perl, Ruby etc. This eliminates the need of learning new vendor scripting language.
For executing scripts created in these languages, you will need to use Selenium Remote Control. If you do not want to use Remote Control than you will need to create your test scripts in HTML format.
So if you are excited about the tool, Lets start playing with Selenium IDE now. If installed properly, Selenium can be accessed from tool --> Selenium IDE in your browser toolbar.
As compared to most of the test automation tools it is very simple and lightweight. The small red button on the right hand side gives you an indication on whether Selenium is in recording mode or not. Also, Selenium IDE will not record any operation that you do on your computer apart from the events on Firefox browser window. So go ahead read your mail, open a word doc or do anything else, Selenium will record only your actions on browser.
If you are curious to know about other options present on the Selenium IDE, there are not much :) . Other options present on the Selenium IDE toolbar are related to test execution. Run will execute the tests with the maximum possible speed, Walk will execute them with relatively slow speed and in step mode you will need to tell Selenium to take small steps.
Final button present on the Selenium IDE toolbar is the Selenium TestRunner. Test Runner gives you nice browser interface to execute your tests and also gives summary of how many tests were executed, how many passed and failed. It also gives similar information on commands which were passed or failed. TestRunner is also available to tests developed in HTML Only.
If you open the option window by going to Option , you will see there are some self explanatory options available. For example, encoding of test files, timeout etc. You can also specify Selenium Core and Selenium IDE extensions on this page. Selenium extensions can be used to enhance the functionality provided by Selenium. Selenium extensions are not covered in this article, there will be a separate article for specifying and developing extensions for Selenium.
Installing Selenium IDE
Install Selenium IDE from http://seleniumhq.org/download/, then restart your browser to enable the new extension.
Select "Selenium IDE" from the Tools menu in Firefox. The Selenium IDE will pop up which looks like this:

By default when the IDE comes up it has recording turned on. You might want to turn it off by clicking on the red button, until you are ready to begin recording. (There is a very subtle difference in the appearance of the red icon in recording mode and non-recording mode so pay close attention.)
Go to a web site that you want to record, click on the record button and begin your browsing task(s). You will notice that as you click and type in the browser the IDE is recording everything you are doing. When you are done, simply end recording and click on the green arrow to play back your script you just created. Don't forget to save your script before closing the IDE.
To give you an example of a good Selenium script I'll show you one that I created. The following script will automatically provide feedback to your last eBay auction. You need to be logged into your eBay account before running the script. You could easily have your Selenium script log you into eBay as well. Here is the script in Ruby code. I like to use the Ruby setting because it makes the source for your script smaller and easier to manage. (To change which format your source gets generated in select Format from the Options pull down menu).
If you want to try this script out, simply go to the Source tab in the IDE and paste the above script in there. Now go back to the Editor tab and click on the Green arrow button. You should now see the actions taking place in your Firefox browser. If you want to slow down the execution select the Walk radio button before playing the script. You may need to increase the pause commands if the web pages are not rendering fast enough, and thus causing an error.
That's all there is to it. If you would rather see how this works before diving in, watch this movie that walks you through the entire process start to finish. This video shows you how to record a google search.
Video iconVideo: showing how to record and play back a google search.
Although they call it an "IDE" (Integrated Development Environment) you certainly can't compare it to something like MS Visual Studio or Eclipse. However it is much more than a simple record and playback tool. You can set breakpoints, It has a debug output window, you can step through your code, and you can set the start or entry point into the script. The one big thing that you might find yourself needing is some kind of flow control such as IF and WHILE commands. I have not done it yet, but it looks like you can add this functionality among others by going to their User-Extensions page.
Selenium IDE