AI-based testing

GUI UFT Mobile and Web tests only

This topic describes how UFT Artificial Intelligence (AI) Features help identify objects the way a person would, enabling you to run the same test on different platforms and versions, regardless of the objects' implementation.

Note: In UFT 15.0, AI-based testing is supported for mobile testing only.

In UFT 15.0.1, desktop web support is added as a technical preview.

What is AI-based testing?

UFT AI Features enable your tests to interact with the application you are testing in the same way a person would. UFT uses AI to identify objects visually, based on a wide variety of images, context, and sometimes text.

For example, UFT AI can identify many forms of search fields, user profile areas, input fields, button, shopping carts and more.

Some advantages of AI-based object identification are: 

1. More intuitive test scripts.

2. Tests are technology agnostic, identifying objects visually, regardless of the UI technology details used behind the scenes.

3. Tests are easier to maintain, as an object changing location, UI framework, or even shape, won’t break the test script as long as the object remains visually similar or its purpose remains clear.

Back to top

Associating text with objects

The text associated with an object can help identify an object uniquely. For example:

AIUtil("input", "USER NAME").Type "admin"

Using the USER NAME text in this step to describe the object, ensures that we type in the correct field.

When detecting objects in an application, if there are multiple labels around the field, UFT uses the one that seems most logical for the object's identification.

However, if you decide to use a different label in your object description, UFT still identifies the object.

Example: When detecting objects in an application, a button is associated with the text on the button, but a field is associated with its label, as opposed to its content.

If a field has multiple labels and UFT chooses one for detection, UFT will still identify this field correctly when running a test step that uses a different label to describing the field.

Back to top

Identifying objects by relative location

UFT must be able to identify an object uniquely to run a step on the object. When multiple objects match your object description, you can add the object location to provide a unique identification. The location can be ordinal, relative to similar objects in the application, or proximal, relative to a different AI object, considered an anchor.

The AIUtil object identification methods now use location and locationData arguments in which you can provide information about the object's location. See AIObject, FindText, and FindTextBlock.

To describe an object's ordinal location

Provide the following information:

  • The object's occurrence, is it first, second, third, and so on.

  • The orientation, the direction in which to count occurrences: FromLeft, FromRight, FromTop, FromBottom.

For example, AIUtil("button", "ON", "FromLeft", 2).Click clicks the second ON button from the left in your application.

To describe an object's location in proximity to a different AI object

Supported on UFT versions 15.0.1 and later

Provide the following information:

  • The description of the anchor object.

    The anchor must be an AI object that belongs to the same context as the object you are describing.

    The anchor can also be described by its location.

  • The direction of the anchor object compared to the object you are describing: WithAnchorOnLeft, WithAnchorOnRight, WithAnchorAbove, WithAnchorBelow.

UFT returns the AI object that matches the description and is closest and most aligned with the anchor, in the specified direction.

For example, this test clicks on the download button to the right of the Linux text, below the Latest Edition text block:

Set latestEdition = AIUtil.FindTextBlock("Latest Edition")
Set linuxUnderLatestEdition = AIUtil.FindText ("Linux", micWithAnchorAbove, latestEdition)
AIUtil("button", "download", micWithAnchorOnLeft, linuxUnderLatestEdition).Click

Back to top

See also: