Monday, August 25, 2008

Selenium IDE(Integrated Development Environment)



Selenium is an open source tool for web application testing. 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

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.
Another tab in the Selenium Options window is Format, As mentioned earlier, Selenium IDE can generate code in variety of languages, this page gives you an option of specifying what kind of formatting you would like in the generated code. For example, what should be the header, how it should be indented etc.

Lets start some action now, In the options, select format and specify HTML as your language choice for your automation. Notice that, when you select HTML as your choice of language, additional tab appears on the Selenium IDE called Table.

There are three columns under this Table - Command, Target and Value. This Table is the crux of how Selenium works. For any element present on the browser, Selenium maps its action in command, target and value. For example, if you want to type user name in the user name text box Selenium would translate it as

command=type , Target=username text box and value=your username

For commands related to asserts, value can be used to compare the value. For example

command=assertText ,Target=Label and Value=somethingtocompare.

In this case Selenium will compare value of the target with the specified value in subsequent execution. Selenium gives you enough functionality in terms of identifying Target. You can locate or identify target using DOM, ID, Name, XPath etc. This helps you in making a robust automation framework. You might find it useful to try Firefox extensions like DOM Inspector or XPath Viewer to get information about the XPath or DOM information of the GUI element under test.

This information should be sufficient for you to explore Selenium IDE and get started with the tool. Lets summarize all the steps involved -

  • Make sure you have installed Selenium IDE in Firefox.

  • Open Firefox and application you want to test

  • Launch Selenium IDE using tools-Selenium IDE

  • By default, you should be in the recording mode, but confirm it by observing the Red button.

  • Select HTML Format.

  • Record some actions and make sure that these are coming on Selenium IDE.

  • During recording if you right click on any element it will show all the selenium commands available.

  • You can also edit existing command, by selecting it and editing on the boxes available.

  • You can also insert/delete commands by choosing appropriate option after right clicking.

  • Choose appropriate run option - i.e walk, run or test runner and review your results.

Hope this article was helpful for you in next article we will discuss how Selenium IDE can be used with Selenium Remote Control to write scripts in different languages. As always, your feedback about this article are welcome :) video

3 comments:

Rajeev said...
This comment has been removed by the author.
Rajeev said...

This is a Very informative Article by Mr.Praveen. Thank you for giving such kind of useful information. Your Posts are really fantastic, we are expecting more and more posts from you sir.

Ultimate Testing said...

Thank you buddy,If I get time I will...