Desi McAdam

February 19, 2007

An Introduction to Selenium IDE

Filed under: Agile, Selenium — desi.mcadam @ 11:51 pm

On my current project we are building a web based application that allows the user to sign up for a service. The signup process is a series of pages for gathering a variety of information (about 8 or so pages). Now… I am a bit on the lazy side so a while back I started using the Selenium IDE to record scripts for moving me to the location in the app that I was interested in. The other day one of the non-techinical folk on the team asked me how to use the Selenium IDE and so I decided to write up a blog post about it. There are a couple of posts out there already in addition to the information on OpenQA but I figure one more post won’t hurt. It really is a very good tool for all types of people from sys admins, PM’s, Business Analysts, developers, to end users doing beta testing. I decided to break up the information based on questions I was asked when showing a couple of folks how to use the app.

What is Selenium?
OpenQA says: Selenium is a UI test tool for web applications. Selenium tests run directly in a browser, just as real users do. Those tests can run in Internet Explorer, Mozilla and Firefox on Windows, Linux, and Macintosh. No other test tool covers such a wide array of platforms.

What is Selenium IDE?
OpenQA says: Selenium IDE is an integrated development environment (thats what IDE stands for for those who don’t know) for Selenium tests. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests. Selenium IDE includes the entire Selenium Core, allowing you to easily and quickly record and play back tests in the actual environment that they will run. Selenium IDE is not only a recording tool: it is a complete IDE. You can choose to use its recording capability, or you may edit your scripts by hand. With autocomplete support and the ability to move commands around quickly, Selenium IDE is the ideal environment for creating Selenium tests no matter what style of tests you prefer.

Installation:
A firefox extension is an installable enhancement to the browser’s functionality and add features to the application or allows existing features to be modified. Since Selenium IDE is a Firefox extension you get it by downloading and installing the firefox extension. Oh and installing extensions does require you to restart firefox so just keep that in mind before you go any further.
1. Go to OpenQA
2. Click the firefox extensions link under the download bullet of the latest version. This will pop up a box and a button should appear briefly that says “Install Now”. Click on that.
3. This will pop up a box and install the extension. Once its finished click the button on the bottom right corner that says “Restart Firefox”.

How do I run/use the Selenium IDE?
The folks over at OpenQA already did a nice movie so you can go watch that to get the basics.

How do I run a script that I recorded in Firefox against Internet Explorer?
You would need to install Selenium Core or Selenium RC in order to be able to do this. Selenium Core has to be run on the same webserver as the application you are trying to test. So this probably won’t work for non-developer types who don’t have access to what is put on the webserver. If that is the case then you might want to look into using Selenium RC.For information on using and setting up Selenium Core take a look Here and for using Selenium RC look Here.

What is the difference between run, walk, and step?
The only difference between run and walk is that run is faster. They behave exactly the same way. Step on the other requires you to actually push the blue downward right angle arrow key to continue to the next step. When you use Run and Walk with breakpoints the pause button will turn into a pause/resume button. In order to keep going to the next breakpoint just hit the pause/resume button. If you hit play again from a breakpoint or from any command it will start the script over from the beginning.

How do I use breakpoints?
Sometimes when you are running your scripts something breaks and you might want to see the state of the application just before that break or maybe the script exits before you get a chance to see the error on the screen in these cases breakpoints are awesome. Simply chose the line in your script where you want it to stop and put a break point. You do this by right clicking and selecting “Toggle Breakpoint”. Now when you hit the play button it will stop at that command. Additionally you can set a break point and then step through the application from that point on using the step feature.

Can you give an example of when you would want to save the scripts in a different language.
Sometimes QA people or Buisness Analysts or even end users may want to submit the test they used to create the error back to the developers, in this case the developers may like to have the test in the language which they are writing the application in. It may also be the case that the developers themselves change the language based on what they were given or who they may be giving the tests to. In order to change the language the test is output in go to the Selenium IDE tool bar select Options -> Format and then select the language you want the test in.

What is the difference between deleteCookie and deleteCookieAndWait?
In a nut shell don’t use the “andWait” commands. The “andWait” commands should be gone as of the latest version (they are still there but they all do the same things as their couterpart commands i.e deleteCookieAndWait does exactly what deleteCookie does) but for those still on the old version here is the explanation. Typically anytime you see the “andWait” or “withWait” piece tacked on to the end of a command it simply means that you want your script to stop executing any additional commands until it gets back a response saying the command has finished.

How would you handle situations where you would need to change a piece of data entered each time you run the script?
To be honest I haven’t quite figured out how to do this. I am going to try to play around with it a bit and see if I can figure something out. As soon as I do I’ll post an answer to this.

What does the log at the bottom tell me and how do I interpret what it is saying?
From the point of view of a non-technical person the log basically just tells you information about what has happened. Maybe you clicked the back button and the ide didn’t recognize that click and you then clicked some image. In this case you would get an error stating it could not find the element you told it to find. As it turns out the script isn’t on the right page so of course it wouldn’t find it. There are lots of reasons why you might get an error and usually if you step through your script you will find that you are not on the page you expect to be when the command was trying to be executed or some other trivial thing has happened. The log also has general information in the info tag that tells you which commands have been executed etc. All this maybe helpful when trying to figure out what has gone wrong.

Gotchas?
The most common gotchas are around timing and caching/session issues. There are a few commands that you can insert into your scripts in order to help you get around this. For instance if you have a page which has some ajax calls then you might have an issue where your script trys to do something before the call has actually finished. In this case you can insert the command “pause” into the script.
In another situation you may want to make sure that you are starting with a fresh session i.e. no cookies. The command “deleteCookie” can be used in order to make sure this happens.
A full list of Selenium commands can be found Here

So now you guys and girls go play around with it and post back your questions here. I’ll do my best to answer them or at least point you in the right direction.

Next post: Selenium On Rails!

Also check out these posts for information on Selenium IDE:

http://dynamitemap.com/selenium/ - very good introduction

http://ajaxian.com/archives/selenium-ide-07-released - some good questions and answers in the comments section

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress