Nexial Automation

Test Automation Platform for everyone!

X

mobile » assertElementsPresent(prefix)

Description

This command instructs Nexial to harvest a set of data variables that match to the form of [prefix]...locator and use the value of such data variables as locators to assert the presence of elements on the current application screen. The [prefix] will be specified via the first parameter. Such data variables must end with .locator. The corresponding data variables can contain any of the supported locators.

Note that this command will attempt to assert all locators regardless of the presence of each targeted element. It will FAIL if one or more target elements ia not found. In other words, it will only PASS if all elements as indicated by the gathered locators are found.

If nexial.verbose is set to true, Nexial would output additional validation output. But a false (default) value will result in error-only output in the execution result.

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

  • prefix - the prefix to gather a set of data variables that contain locator for “element presence” test.

Example

Consider the following data sheet contains 3 data variables prefixed with add.:

We can validate all 3 locators via this single command:

See Also