mobile » saveAttributes(var,locator,attribute)
Description
This command searches for all elements matching to the specified locator
, collects the value of the specified
attribute
from these elements, and saves these values as a LIST to a data variable denoted as var
. If no element is
found to match locator
, then var
will be removed to avoid confusion. For each matching element, Nexial will attempt
to collect the value of attribute
from it. It is quite possible that the specified attribute
might not exist on one
or more of the matching elements. In such case, a null
value will be collected to represent such condition.
Nexial provides 2 wait strategies in regard to locating elements. In both cases, they are configured via the
corresponding “profile” and the use of the use(profile)
command.
Implicit Wait
The idea of implicit wait is to suspend execution for a specified amount of time before proceeding to finding the target element. The wait time is specified in millisecond.
To specify implicit wait, use the following configuration for your profile:
[PROFILE].nexial.mobile.implicitWaitMs=<millisecond>
If this configuration is not specified, the System variable by the same name -
nexial.mobile.implicitWaitMs
- will be used instead.
Specifying this configuration thus override the system default. If [PROFILE].nexial.mobile.implicitWaitMs
is specified
with a value less than 200 (millisecond), the system default will be used instead. Any wait time that is 200 or less
would not likely to be fruitful.
Explicit Wait
Explicit wait is different from its implicit counterpart in that the specified wait time is not exercised prior to finding the target element. Instead, Nexial polls for the target element every 10 millisecond until either the element is found or the specified wait time is passed - whichever comes first. Hence, the specified wait time is the maximum amount of time to wait (i.e. tolerance) before consider the target element as non-existent. This form of wait is generally preferred as the automation generally runs faster and with less flakiness.
To specify explicit wait, use the following configuration for your profile:
[PROFILE].nexial.mobile.explicitWait=<millisecond>
If this configuration is not specified, the System variable by the same name -
nexial.mobile.explicitWaitMs
- will be used instead.
Specifying this configuration thus override the system default. However, if [PROFILE].nexial.mobile.explicitWaitMs
is specified with a value less than 200 (millisecond), then Nexial will consider explicit wait DISABLED.
Consequently, disabling explicit wait would activate implicit wait.
About locators
Note that for mobile automation, there are some differences in locators between Android and iOS devices. Check the
the Locator section for the various options of specifying a locator. Unless there are strong
justification such as performance lag or platform-specific workaround, the recommendation is to use locators that are
common to all mobile devices – namely, ID (id=...
), Accessibility ID (a11y=...
) or XPATH (xpath=...
).
Parameters
- var - the data variable to save the collected attribute values
- locator - to match one or more elements
- attribute - the attribute to inspect and collect