Defining a variable to run a test with a selected browser

If you run a test from the command line, as part of a schedule from IBM® Rational® Performance Tester, or from IBM® Rational® Quality Manager, you can define a variable in the test to specify the web browser to use for running the test. The reserved name for the variable is RTW_WebUI_Browser_Selection. After defining the variable, if you run the test from test workbench, the browser selected in the Run configuration dialog box takes precedence over the browser specified in the variable.

Before you begin

Now, IBM® Rational® Functional Tester creates a test variable automatically whenever a new Web UI test is recorded or when an old test is used that does not already have this variable defined.

Procedure

  1. In the Test Navigator, browse to the test and double-click it.
    The test opens.
  2. To create a container for the test variables that you create in a test:
    1. Open the test, and in the Test Contents area, at the top of the test, click Test Variables.
    2. Select Add > Test Variables Containers.
      A container named Test Variables is created for the user-defined variables.
    3. Select the container to rename it.
      The Test Variables Details area opens for you to type a new name in the Name field.
  3. To define a variable in a test:
    1. Select the newly created test variable node.
    2. Click Insert > Variable Declaration.
    3. Enter the name of the variable, which is a reserved name for this selection variable: RTW_WebUI_Browser_Selection.
    4. Click OK.
    5. In the Visible in section, select This test only to restrict data to the current test only. Even if another test has a variable with the same name, that variable will not change. Select All tests for this user to share the value of this variable when the test runs in a compound test. For the variable to be shared, both tests must have a variable with the same name and must have this option enabled.
  4. Assign a specific value to the variable and initialize the variable:
    1. In Initial Value, ensure that the Text option is selected.
    2. Use one of the following variables to specify a browser:
      Browser Variable Variable short form
      Mozilla Firefox Firefox, Mozilla Firefox ff
      Google Chrome Chrome, Google Chrome chrome
      Internet Explorer v9 32-bit Internet Explorer, Microsoft Internet Explorer ie
      Internet Explorer v9 64-bit Internet Explorer, Microsoft Internet Explorer ie64
      Internet Explorer v10 and v11 Internet Explorer, Microsoft Internet Explorer ie
      Microsoft Edge Edge, Microsoft Edge edge
      Apple Safari Safari, Apple Safari safari
  5. Save the test.

What to do next

You can now run the test from the workbench, from the command line, as part of a schedule, or from Rational® Quality Manager.

You can use this test variable in If conditions to assign different behavior for different browsers. Doing so allows you to create more robust tests that will run successfully in more than one browser.