Defining a variable to run a test with a selected mobile device

To be able to launch subsequent tests in the same logical flow (session) from the same devices, you must define a variable including a reserved variable name and selection criteria related to one or multiple devices.

About this task

Defining variables is applicable to Android, iOS, hybrid and Web UI applications.

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, click Test Variables, at the top of the test.
    2. Select Add > Test Variable Container. A container named Test Variables is created for the user-defined variables.
    3. Select the container to rename it. The Test Element Details area opens for you to type a new name in the Name field.
  3. To define a variable in a test:
    1. Open a test and select the 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_Mobile_Device_Properties or RTW_Mobile_Selected_Device
    4. Click OK. The variable is added as the last element in the container and the Test Element Details area opens.
    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. Select Text
    2. Enter a selection sentence to assign a variable value to a text string. Enter selection strings including a device’s property, followed by an operator value, property’s value and a comma separating each string. For more details on the main device properties you can use and on the syntactic rules, see the Variable selection values topic.

Results

The variable can then be initialized from some external source (a datapool, tests from an IBM® Rational® Quality Manager test suite, or tests from the same user in compound tests containing one or more mobile tests. It can also be set within a test’s execution with a variable assignment action from any data source, including a data correlation reference, custom code, built-in function, datapool, or string constant. As a result, successive tests in the same session will then be sure to run on the same actual devices.

Note: When a test launches an application:
  • The RTW_Mobile_Selected_Device variable content is checked to get the device ID
  • The device is reused if it is still applicable to the app that must be launched. Conditions:
    • The device operating system must be the same as the operating system of the application to be launched.
    • The tester app is installed or can be installed without user intervention.
  • If the conditions are not matched, the content of the RTW_Mobile_Device_Properties variable is checked
  • If this variable is set, the first device matching all the valid property expressions of the variable is selected
  • If the variable is not set, the first applicable device ready for test is used. Conditions:
    • The device operating system must be the same as the operating system of the application to be launched.
    • The tester app is installed or can be installed without user intervention.
Feedback