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
First I’ll record the Siteport login process in Selenium IDE:
Now I’ll open Selenium IDE (Ctrl+Alt+S) and record the login process.
Once this is done, we need to manually add the command “Store” to create the variable for the Username.
Here is our information for the variable,” MyUserName”.
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.
In Siteport, click on the “Add Migration” button.
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”:
Now we’ll run the Test Case.
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.
Storing variables in Selenium IDE:
Store Commands and Selenium Variables: