Passing variable values to Selenium script

In some cases, you prefer not to input real values in the Selenium script for security or customizing considerations. For example, you do not want to input the password directly in the script and you want to specify the password later in Cloud App Management console. To achieve this goal, you can store and use variables in the script and specify real values for the variables in Cloud App Management console when you create a Selenium script test. These variable values can be passed from Cloud App Management console to the Selenium script.

Procedure

  1. Record a Selenium script test. See Creating a Selenium script test.
  2. If you want to use variables for some commands instead of using real values, you need to change the script in Selenium IDE. For example, if you use variables for the type command, take the following steps:
    1. Create a store command to store a variable in Selenium IDE. Right-click the row where the type command is and select Insert new command. Click the new row that is inserted and select store from the Command list. Set the Value field with the variable name you want, such as username. Leave the Target field blank or with a default value.
    2. Click the row where the type command is again and change the Value field based on the variable name that you set in the last step. Enclose the variable name in curly brackets ({}) and precede it with a dollar sign. Example: This image shows how to use the variables in the Selenium script.

      In this example, the variable username is stored with the default value demo and the type command uses the username variable.

  3. Create a Selenium script test. You can change the variable values under the Script variables section in Cloud App Management console. For more information, see step 4 and step 10 of the topic Creating a Selenium script test.