Declaring test variables to select a mobile device

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

About this task

Declaring a test variable 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 Variables Details area opens for you to type a new name in the Name field.
  3. To declare 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 for the mobile device selection as Mobile_Device_Selection.
      The variable is automatically initialized to the name of the Android device or emulator where the recording of test was performed.
    4. Click OK. The variable is added as the last element in the container and the Variable 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 devices property, followed by an operator value, propertys 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 dataset, 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 tests execution with a variable assignment action from any data source, including a data correlation reference, custom code, built-in function, dataset, 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 Mobile_Device_Selection 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.