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



46 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………………….

26

monisha

July 6th, 2009 at 4:42 am

Great effort.Very nicely explained.Thanks so much.

27

Satyabrata

July 23rd, 2009 at 4:58 am

Nice tutorial for a beginner to understand Selenium..

28

Manik

August 3rd, 2009 at 10:12 pm

while recording on selenium i found that drag and drop element is not get recorded in it.If i manualy insert draganddrop command in selenium it won’t works.Anyone can give me solution for that….

29

Manik Yadav

August 3rd, 2009 at 10:19 pm

In my site,there are sub tabs under main tabs.If i start execution test case in selenium, it recognise the main tab but false to recognise sub tabs.Help me…

30

Guambino

August 4th, 2009 at 10:24 am

Hi, I using Selenium for my webtest and yet I have an event OnChange in my inputs tag and Cant get Selenium to call it. Any ideas on how to?

31

hanna

August 20th, 2009 at 11:25 pm

this is so important , but how can i know about the others command?

sameer

August 21st, 2009 at 3:24 am

A list of selenium commands and usage details can be found here:

http://seleniumhq.org/docs/04_selenese_commands.html

33

shubharajesh

August 24th, 2009 at 8:32 am

Hi Sameer,

Thanks for this help site. It will be helpful if you can show some more advanced features.

Thanks
Shubha

34

Jaidev

August 26th, 2009 at 3:57 am

Hi Sameer,

Is it possible to test citrix based applications using selenium?
Please advise.

sameer

August 26th, 2009 at 4:21 am

I’ve not really worked on Citrix products; used GoToMeeting and GoToMyPC a couple of times, but I cannot really advice you on that.

36

Rajiv Walia

August 27th, 2009 at 4:44 am

This is very helpful for me as a beginner. It will be very beneficial for all the software testers who are interested in automation testing.

Waiting for advanced version :)

http://puretest.blogspot.com

37

Ranjan

September 24th, 2009 at 5:19 am

How to run/execute 10 test cases at a time
or there any option to give time to run test cases

sameer

September 24th, 2009 at 5:29 am

You will need to create a ‘Test Suite’ of test cases, which will run one by one (not parallel) on execution.

39

Ann

October 28th, 2009 at 5:19 am

My URL is on an intranet so not accessible to you. Can I save my recorded test as HTML and run it on a different browser such as IE 7?

sameer

October 28th, 2009 at 5:46 am

Selenium IDE is not available for IE, but you can run the recorded tests using Selenium RC and IE.

41

bharat

November 10th, 2009 at 11:06 pm

Hi sameer,
nice tool for me as beginner.
what about drag and drop testing ??
plz suggest

42

Kevin

November 12th, 2009 at 8:51 am

Nice tutorial….eagerly awaiting part 2

43

kdnc

December 16th, 2009 at 8:16 pm

Nice tutorial for the beginners….

44

Umer Saleem

February 10th, 2010 at 3:55 am

Simple but makes sense…

Keep it up

45

Susan Martin

March 9th, 2010 at 7:55 pm

while creating a test for site, command icons on IDE greyed out and do not respond when selected. I dismissed and restarted FFox - brought up the Selenium IDE 1.0.5 again - and icons are still grey. Reimported the last test recorded, and ensured the record button is off.. any ideas?

sameer

March 10th, 2010 at 6:18 am

Check to see if the ‘IDE > options > format’ is set to HTML.

Comment Form

Use the html <code> tag to insert small source code snippets

For longer code examples use http://pastie.org/.

Get latest updates by E-mail

About this blog

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

Recent Comments

  • sameer: Check to see if the 'IDE > options > format' is set to HTML. [...]
  • sameer: Google strips any newline characters form the text. Although it does accept it with the online trans [...]
  • Arjan: Fiddler is a debugging tool for IE (not Microsoft's Fiddler) [...]
  • Susan Martin: while creating a test for site, command icons on IDE greyed out and do not respond when selected. I [...]
  • Saar: Thanks for this example. helped me a lot. I have 1 problem, I am translating chunks of code, but I [...]
  • sameer: You can add extra GET variables in the options array as below: $pager_options = array( 'mode [...]
  • Martin: How can you carry over your own variables into the URL? I am using a form to POST a couple of var [...]
  • nancy: thanks very much ! first tools [...]

  • Users Online

    • 8 Users Online
    • 8 Guests