You can use the value of a UI object property and assign the value to a test variable
in all the UI tests created for Android, iOS, hybrid, or native mobile applications, desktop
applications, and web applications in IBM® DevOps Test UI (Test UI). The process of assigning a
variable to an object property is called a variable assignment.
You can extract a substring from the content of an object property by using a regular
expression and then assign the substring to a variable. For example, you can extract
User Documentation from the Content property of a hyperlink, and then
assign the string to the trimVar variable. Further, you can include
trimVar in the subsequent steps and execute the test. You can view the
variable value User Documentation in the unified report.
You can also use variable assignment to check if an object exists and return
true or false to the variable. Further, based on the
value of the variable, you can choose to branch the test steps by using an
If-Else block. For example, you can assign the
check_state variable to the property of the Login button, and then use conditional
statements to either log in or not.
You can create variable assignments in all the UI tests that are created for Android, iOS,
hybrid or native mobile applications, desktop applications, and web applications.
Note: When you run a test from the mobile client on mobile devices,
it uses the same values that you used during recording. If you modify the test
script and create a dataset or variable, or if you add a condition, a loop,
custom code, references or add other statements, they are not taken into account
by the mobile client at run time. To verify that the initial recorded values are
substituted with variable data, you must initiate the test run from Test UI.
-
Open the test, and in the Test Contents area, select a test
element.
-
Select .
The Test Editor window opens and lists the variables available
to the test.
-
Select the variable for which you want to assign a value, and then click
OK.
A variable assignment statement is inserted before the selected element.
-
Select UI object property in the Set to
box in the Variable Assignment Details area.
-
Select the values for the following fields:
| Option |
Description |
Action |
| Graphic object |
This option lists the objects that you can select for variable
assignment.
Depending on the graphic object that you select, the corresponding options
are displayed in the other UI elements of the Variable Assignment
Details panel.
|
Select an object from the list. |
| Object identified by |
This option lists the identifiers of the selected object. |
Select an identifier such as Xpath or Id of the object from the
list. |
| Object location |
This option lists the possible locations of the selected object.
For example, the Login button can be below a checkbox
on a page when you recorded the test.
|
Select the location of the object from the options provided in the list and
then provide the values.
The default value is (automatic detection).
|
| Object's property |
This option lists the properties of the selected object that must be used
for variable assignment. |
Select one of the following options from the list:
- Select a property such as Title, Content, or Xpath of the object that must
be used to extract the value using a regular expression.
Go to step 6.
- Select Exist to verify whether the selected object
exists and returns the value to the variable.
Go to step 7.
|
The values of the properties displayed in the lists are different for web, Android and
iOS apps.
-
Enter a regular expression to extract a substring from the value of the object property
in Extract value using Regex.
-
Save the test.
A set statement is added to the test with the value you chose.
For example, the
following set statement is added if you selected
Extract value using
Regex:
Variable 'trimVar' is set to 'Extract value using regex User(.*)' from property 'Content' of Hyperlink whose Content is User Documentation located at position 1
If
you selected
Exist, the following set statement is
added:
Variable 'trimVar' is set from property 'Exist' of Heading H4 whose Content is User Documentation