Selenium IDE Tutorial - Part 1


Posted in: browser, php, tools, tutorial | Save to del.icio.us | Twit This! 8 Oct 2008

Selenium IDE is an integrated development environment for performing Selenium tests.  Selenium tests can be written as HTML tables or coded in various languages like C#, PHP, Perl, Python and can be run directly in most modern browsers.The IDE can help you to record, edit and debug tests. Currently the IDE is only available for Firefox (as if we developers will use any other) as a addon.

Here is a possible scenario for using Selenium. Imagine you have created a HTML form with about twenty fields and you have to repeatedly test the form. Filling the form every time can quickly become tedious. With Selenium you can automate the whole process and run the test as required. In this part we will see how to create a simple test in Selenium. So let’s get started.

STEP 1 - installation :

You can download Selenium IDE from this locations.
http://selenium-ide.openqa.org/download.jsp
https://addons.mozilla.org/en-US/firefox/addon/2079
Once the addon is installed make sure you do not forget to restart Firefox.

STEP 2 - running a simple test :

a. Start Selenium IDE  in Firefox: Tools->Selenium IDE. You will see the following popup.

selenium

b. Click on the red record button on the right.
c. Browse to Google.com and enter ’selenium’ in the search box and click enter.
d. Click on the first result, which is that of selenium.openqa.org.
e. Stop the recording by clicking on the record button.

You should see something like below. If you click on the ‘ Source’ tab you can see the test html generated by selenium.

selenium ide

The ‘table’ tab shows the commands recorded by Selenium.

f. Open a new tab in Firefox and click on the Selenium IDE’s play button to run the recorded test.

selenium ide

The IDE should play your recorded test. After the test is complete you should have landed on the selenium page (http://selenium.openqa.org/). The IDE after the test run is shown below. In the ‘Log section’ you can see the various events run by the test. In the table tab you can see that all the rows are green, which means that the test ran successfully.

selenium test run

Now lets add a small assertion to the above test.

a. Click on the blank line below after the last ‘clickAndWait’ command and insert ‘assertTextPresent’ command from the drop down box as shown below. You should see something like this.

This test checks to see if the text ‘Selenium News’ is present in the last rendered page. Run the test again and you should see that the test has run successfully. No try replacing the text with something that is not present on the page, take for example ‘elvis’ and run the test again. Now the test fails and you should get the screen below.

You have just completed your first test run. And it was so simple.

‘assertTextPresent’ is one of the hundreds of commands available for your testing needs. Just browse throught the command drop down to get a feel of what you can you get.

In the next part we will see more advanced features of Selenium.

Share this post

Share on Facebook
Share on Twitter
Share on StumbleUpon
Share on Delicious
Share on Digg
Share on Technorati
Share on Reddit
Feeds RSS Subscribe to site Feed

Other related posts

25 Responses

1

jack

October 10th, 2008 at 9:08 pm

nice! waiting for part two.

2

Rajasekaran

November 4th, 2008 at 5:41 am

Easier to Understand tool

3

Rajasekaran

November 4th, 2008 at 5:42 am

Easier to Understand tool flow

4

meenakshi

November 18th, 2008 at 11:13 pm

When you are publishing part 2….

sameer

November 19th, 2008 at 7:09 am

Tied with project work. But expect to see the 2nd part in a couple of days. Thanks!

6

Jean-Michel

November 20th, 2008 at 3:21 am

Nice first tutorial :)
I’m waiting for the part when it is about rollup rules… I’m quite lost at the moment !
Thanks anyway

7

Niti Tayal

December 1st, 2008 at 10:01 pm

Nice tutorial, it is really beneficial

8

R. M. Shiblee Mehdi

December 6th, 2008 at 1:48 am

Thanks. I was searching more tutorials. :)

9

Lipika

December 28th, 2008 at 11:17 pm

Thanks…. It is really very helpful…

10

Asha

January 9th, 2009 at 2:27 am

I have seen that there is a button named ‘play with selenium test runner ‘ in Selenium IDE. But I haven’t seen anything regarding the same in this tutorial .What is advantage of playing selenium with test runner ? Is it possible to set start point while using the same or it will run only a full test ? can u please help me ?

11

Nikhil

January 27th, 2009 at 1:30 am

It’s nice waiting for next part

12

sree

January 29th, 2009 at 5:29 am

very useful tutorial ..

13

Ankur Agarwal

February 25th, 2009 at 12:11 am

Nice Tutorial

Cheers..
Ankur

14

Abhishek Saxena

February 26th, 2009 at 10:27 pm

Hi!
This Tool is Very useful and Easier to understand than other Automation tool.

15

Madhukar M R

March 23rd, 2009 at 6:36 am

Hi,
I have followed your directions and Selenium IDE could record and playback. I could also save the script. I first saved with out an extenstion. Then I renamed it to have .html extension.
Now, if I restart selenium IDE and firefox browser and try open the script just saved or any other script, it fails to show it. Only if I remove Selenium IDE from Firefox Add ons window and add it again, it starts showing up again.
How to fix this problem?
–Madhukar

sameer

March 23rd, 2009 at 7:06 am

I could not replicate your problem at my end. Try reinstalling firefox and selenium IDE and see if it works. It could also be that some Addon is conflicting with your selenium ide, try disabling all other extensions and then try again.

17

Madhukar M R

March 25th, 2009 at 7:13 am

Sameer,
Thanks for your input. I have got the Firefox browser reinstalled. And, this time I used Firefox browser for downloading selenium IDE that given addon install window. Now, I the problem disappeared.
–Madhukar

18

Baskar

April 1st, 2009 at 12:46 am

Very easily explained to be able to understand without any doubt. Good job. Thanks for your efforts. Keep continuing.. - Baskar

19

Murali Gowda

April 6th, 2009 at 1:03 pm

how to add if tool does not record the object?

20

sahithi

May 10th, 2009 at 10:18 pm

How can i set the window in selenium Ide if Window name is unique for each run?

21

ramesh

June 22nd, 2009 at 4:22 am

This was really helpful

22

Shoeb Khan

June 23rd, 2009 at 1:28 am

I just learned Selenium basic from you!!!!!

23

Arpit Desai

June 23rd, 2009 at 3:03 am

How can i record change event through Selenium? I have a requirement to call change event with the text entry which will enable the following button to proceed further, but Selenium is just copying the text, it’s not entering the text, so change event does not fires…

sameer

June 23rd, 2009 at 4:40 am

After you enter some text in a field using say the ‘typeKeys’ command, you will have to explicitly fire a event for the same text box using the ‘fireEvent’ command, and passing the ‘change’ (note: its not ‘onchange’ ) event in the value field.

25

sandamal

July 2nd, 2009 at 3:51 am

Thanks.. Really Usefull………………….

Comment Form

About this blog

This site is a digital habitat of Sameer, a freelance web developer working from Pune.More

On Twitter

Posting tweet...


  • Users Online

    • 1 User Online
    • 1 Guest
  • Categories