Woman using computer
Testing Development

Using variables in Selenium IDE

Feb 17, 2014
Lorena Espinosa
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: Log In to Siteport

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

    Siteport login

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

    Selenium IDE

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

    Add Store command

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

    MyUserName variable

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

    dynamicMigrationName variable

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.

    Add Migration in Siteport

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

    Create dynamicMigrationName

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

    dynamicMigrationName variable

  3. Now we’ll run the Test Case.

    Test Case

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

    The new migration has been created

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.


Related insights