Creating and assigning test variables

You can create a variable and initialize it to an alphanumeric value. Then, within the test, you can assign the value of the variable to a test element.

Before you begin

You must have completed the following tasks:
  • Ensured that you are assigned a Team Space Owner, Project Owner, or Member with a Tester role to create or edit a test resource.
  • Read and understood the information in Edit branch overview and Create or select an Edit branch.
  • Ensured that your project contains a Web UI test.

Procedure

  1. Click the Edit button displayed on the Test Editor page.

    The Edit button appears only when no active edit branch is selected.

    Alternatively, right-click the test in the test navigator panel and select Edit.

    The Edit branch dialog is displayed.
    If the Edit branch dialog is not displayed, then go to step 3.
  2. Select an existing branch or create a new branch.
  3. Click the Configure settings and data step in Test Editor.
    The Configure settings and data pane is displayed.
  4. Click Add icon in the Variables section.
  5. Enter a name for the variable in Name.
    The name must start with an alphabet, $, or _ and the name must not be a reserved keyword or contain a space.
  6. Enter a value for the variable.
    The newly created variable is listed in the Variables section.
    The default variable type is Input.
  7. Optional: Click the variable icon to change the type to Output or Local.
  8. Perform the following steps to assign a variable to a test element:
    1. Select a Type or Select step for which you want to replace the value with the value of a variable.
      The step details pane is displayed.
    2. Enter the variable name in the Value field for the selected UI Object in the following format:
      ${variable_name}

      For example, you can replace the text that is saved in the text field for username with the value of the variable, user_name.

    3. Close the step details pane.
      The test step is updated with the variable that you chose.
  9. Click the Save icon to save the modifications.

Results

You have created a variable and assigned the value of the variable to a test element.
Note:
The variables that you created in Test Editor are listed in the Variables section of the Configure settings and data pane as test variables.

What to do next

  • Run the test in Test Editor and view the Functional Report to verify the test steps with the variable assignment. See Running a Web UI test.
  • Start the test run from the Execution page, and in the Execute test asset dialog, navigate to the Configure settings and data option on the Test Editor page to view the Test variables defined in the test. See Configuring a run of a Web UI test and Variables.