Using variables in Selenium IDE

Feb 17, 2014
Lorena Espinosa

Using variables in Selenium IDE can be a great help when a manual test takes too long and there are values ​​you want reuse within the test.  

With the Selenium IDE command “store” you can specify a variable and its value to use later in the test suite. This will allow you to create a variable in one test case and retrieve the value in other test case, as many times as you need.

Today I’ll show you how this works by recording a Selenium test for Siteport.Siteport is an automated migration solution that Oshyn uses to save time and resources when refactoring, redesigning or replatforming a website’s CMS.

In the first Test Case I will use the variable “MyUserName”.Then in a second test case, I’ll use the variable “MyUserName” to create a new migration with the value stored in the “MyUserName” variable.

Test Case 1: Login in Siteport

1First I’ll record the Siteport login process in Selenium IDE:


2. Now I’ll open Selenium IDE  (Ctrl+Alt+S) and record the login process.

3. Once this is done, we need to manually add the command “Store” to create the variable for the Username.

4. Here is our information for the variable,” MyUserName”.

5. I’ve also added the variable “dynamicMigrationName” that will represent the “Username + Current System Date". For this example, the “dynamicMigrationName” will have the value  “QATester-MM-DD-YYYY”.


Test Case 2: Add a migration

In the second test case, I’ll add a migration in Siteport that uses the stored variable information.

1. In Siteport ,click on the “Add Migration” button.


2. In the field where the user inserts the name of the migration, I’ll call the variable “dynamicMigrationName”.



In the type command, the value will correspond to the variable “dynamicMigrationName”:

3. Now we’ll run the Test Case.

4. The new migration will be created and the name will correspond  to the variable name. 

As you can see, the use of variables is a helpful feature in Selenium IDE. It proved very useful in my example above, but for test automation, each QA team should evaluate the need of variable according to each project.


References:

Storing variables in Selenium IDE:

http://webigniter.wordpress.com/2011/04/07/storing-variables-in-selenium-ide/

Store Commands and Selenium Variables:

http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#commonly-used-selenium-commands