Selenium IDE Tutorial – Part 1


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.

This site is a digital habitat of Sameer Borate, a freelance web developer working in PHP, MySQL and WordPress. I also provide web scraping services, website design and development and integration of various Open Source API's. Contact me at metapix[at]gmail.com for any new project requirements and price quotes.

62 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.

47

Mohamed

March 15th, 2010 at 5:17 pm

That’s a great easy explanation … well done

48

Ed

March 26th, 2010 at 1:10 pm

Hello i followed your instructions but got an error saying
[error] your browser doesnt support Xml Http Request

[info] Executing: |click |//input[@value='Google Search' and @type='button']||

[error] Element//input[@value='Google Search' and @type='button']not found

sameer

March 26th, 2010 at 10:43 pm

50

Priya D

March 28th, 2010 at 11:36 pm

Hi Everybody,

I’m using Selenium IDE 1.0.5 on Firefox 3.5 for web application in php but getting Timed Out error. I changed it from Option> Option> Default timed out but still getting error. Even used “setTimeout” command of selenium but gives error as unknown command. PLease if anybody knows the solution please help me.

Thanks!!

51

Priya D

March 29th, 2010 at 5:13 am

Hi Sameer,

Can u tell me please how to configure Selenium RC with PHP. I cud not find it on http://seleniumhq.org/docs/05_selenium_rc.html#perl-php

I have downloaded selenium RC but unable to use it as no any information is available for PHP applications

U can mail me details on priya.ud@gmail.com

Thanks!

52

Ed

March 29th, 2010 at 1:36 pm

Hello Sameer
New to this but will learn, reading all kind of info, but seems you are the Master.
My problem is on the site i am testing navigation header has a link to a pdf when i click on the pdf it opens but selenium gives an error

[warn] Link has target ‘_blank’, which is not supported in Selenium! Randomizing target to be: selenium_blank18660

when the pdf opens in another window a new browser window opens untitled

i tried to insert a go back with link but still no luck, can you please help

[warn] Link has target ‘_blank’, which is not supported in Selenium! Randomizing target to be: selenium_blank18660

sameer

March 29th, 2010 at 8:59 pm

Hello Priya
I’ve detailed the process of running Selenium RC with php in part 2 of the tutorial.

http://www.codediesel.com/php/selenium-ide-tutorial-part-2/

sameer

March 29th, 2010 at 9:20 pm

Ed!

Are you using javascript to open the pdf link or plain HTML. Also did you download the latest Selenium IDE release. The error occurs because selenium cannot get the id of the new window. Try giving the new window some title. More information about the bug can be found here:

http://old.nabble.com/selenium-IDE—select-window-%27_blank%27—your-help-please-:%29-td9044960.html

55

Priya D

March 30th, 2010 at 3:50 am

Hi Sameer,

Thank U Very Much!!

56

Ed

March 30th, 2010 at 8:49 am

sameer

Thank you so much that did the trick, now i have another issue, i saw it on the google selenium users but no answer.

I was able to open the pdf page with no error but now i am trying to close it and go back to the original page

I did a
close
http://www.vyvanse.com/pdf/prescribing_information.pdf

and

close
http://www.vyvanse.com/pdf/prescribing_information.pdf

and got this error

close
http://www.vyvanse.com/pdf/prescribing_information.pdf

What am i doing wrong.

Thanks

57

Ed

April 6th, 2010 at 1:11 pm

Hello sameer

i read my own post and made no sense at all, sorry Sir.
My problem is now i am trying to close the pdf’s i opened and hace use close or windowselect and i am still getting errors.

this is where i am

Focus euro stage

Focus euro stage

open
https://vyvansefocus-b.erweb.eurorscg.com/

openWindow
http://www.vyvanse.com/pdf/prescribing_information.pdf

selectWindow
null

openWindow
http://www.vyvanse.com/pdf/medication_guide.pdf

selectWindow
null

open
https://vyvansefocus-b.erweb.eurorscg.com/Register.aspx

58

John Danny Morales

April 7th, 2010 at 2:52 am

I have downloaded and installed the latest Selenium IDE dated March 26, 2010. However, when I start using it, the “Table” tab is disabled and the other functions are ALSO disabled. The only option available is the “Record” icon.

Is there something wrong or did I install it incorrectly?

sameer

April 7th, 2010 at 2:55 am

Make sure that the IDE ‘options > Format’ is set to ‘HTML’.

60

Ed

April 12th, 2010 at 10:10 am

Hello Sameer

I have been trying to close 2 pop up windows and i am having trouble identifying them in order to close them , can you please help. Thanks

open
https://vyvansefocus-b.erweb.eurorscg.com/

assertTitle
Vyvanse® (lisdexamfetamine dimesylate) CII Patient Support

openWindow
http://www.vyvanse.com/pdf/prescribing_information.pdf

selectWindow
http://www.vyvanse.com/pdf/prescribing_information.pdf

close
http://www.vyvanse.com/pdf/prescribing_information.pdf

openWindow
http://www.vyvanse.com/pdf/medication_guide.pdf

selectWindow
http://www.vyvanse.com/pdf/medication_guide.pdf

open
https://vyvansefocus-b.erweb.eurorscg.com/Register.aspx

this is the error i a am getting and i have not been able to figure out how to close the 2 pop up windows that are in the format of PDF

* [info] Executing: |open | https://vyvansefocus-b.erweb.eurorscg.com/ | |
* [info] Executing: |assertTitle | Vyvanse® (lisdexamfetamine dimesylate) CII Patient Support | |
* [info] Executing: |openWindow | http://www.vyvanse.com/pdf/prescribing_information.pdf | |
* [info] Executing: |selectWindow | http://www.vyvanse.com/pdf/prescribing_information.pdf | |

* [error] Could not find window with title http://www.vyvanse.com/pdf/prescribing_information.pdf

sameer

April 12th, 2010 at 11:16 pm

Hello Ed!
Sorry for replying so late. Instead of opening the pdf’s with ‘openWindow’, use Javascript to open the pdf’s with the ‘Window.open’ method, passing a window name, say ‘mywindow’. Assuming that link name is ‘pdf1′, the following should work.

A example is posted here.

http://www.codediesel.com/data/selenium/index.html

Check the source to get the idea.

The Selenium test case for the above link is here:

http://www.codediesel.com/data/selenium/popup_testcase

Note there will a 30 second delay after the ‘waitForPopUp’ command.

62

Raghu B

April 14th, 2010 at 10:19 pm

Hi Sameer,

The IDE does not play the recorded flow.Please help me in this regards.

Thanks in advance.

Comments are disabled for this post, but if you have spotted an error, feel free to contact me.