AIUtil Object

This object is provided as a technical preview.

Description

A utility object for Artificial-Intelligence-based (AI-based) testing.

AI objects are supported in UFT only when the UFT Web Add-in and Mobile add-in are installed and loaded.

IMPORTANT

Operations

The sections below list the built-in methods and properties that you can use as operations for the AIUtil object.

Property AIObject Creates an AIObject for the specified control. The control can be specified by type, and for some control types, by the object text.
Property FindText Creates an AITextObject object for the specified text. This may be partial text within a larger block of text.
Property FindTextBlock Creates an AITextObject object for the specified text block.
Method SetContext Sets the top-level object in which to use AI. (Currently only Mobile Device is supported)

 

AIObject Property

Description

Creates an AIObject Object for the specified control. The control can be specified by type, and for some control types, by the object text.

If there are multiple similar objects on one page in the application, use the object's relative location in the application to describe it uniquely.

Syntax

One of: 

object ControlType, [Text], [Orientation], [Occurrence]

object.AIObject ControlType, [Text], [Orientation], [Occurrence]

Arguments

Parameter Description
ControlType Required. A String value.
The type of the control. For a list of supported control types, see the UFT Help Center.
Text

Optional. A String value.
The text to use to identify the control. For a list of control types that support recognition by text, see the UFT Help Center.
Enter the micNoText constant if you want to ignore this parameter and provide values for Orientation and Occurrence.

Orientation

Optional. A predefined constant or string value. Mandatory if you specify a value for the Occurrence parameter.
The direction in which to count when referring to an object's location in the application.
Possible values: 
Strings: "FromTop""FromLeft", "FromRight", "FromBottom".
Constant values: micFromTopmicFromLeft, micFromRight, micFromBottom.

Occurrence

Optional. An Integer value. Mandatory if you specify a value for the Orientation parameter.
The ordinal number of the object that you are referring to, starting with 1 for the first object.
UFT counts the objects that match the description, in the direction specified in the Orientation parameter.

Return Type

An AIObject Object.

IMPORTANT

The AIObject property is the default property for the AIUtil object.

You can therefore omit the word AIObject in the syntax, and perform AIObject methods directly on the returned object within the same statement, as you can see in the example below.

Example

Back to top

 

FindText Property

Description

Creates an AITextObject Object for the specified text. This may be partial text within a larger block of text.

If there are multiple similar objects on one page in the application, use the object's relative location in the application to describe it uniquely.

Syntax

object.FindText Text, [Orientation], [Occurrence]

Arguments

Parameter Description
Text

Required. A String value.
The text to find.

Orientation

Optional. A predefined constant or string value. Mandatory if you specify a value for the Occurrence parameter.
The direction in which to count when referring to an object's location in the application.
Possible values: 
Strings: "FromTop""FromLeft", "FromRight", "FromBottom".
Constant values: micFromTopmicFromLeft, micFromRight, micFromBottom.

Occurrence

Optional. An Integer value. Mandatory if you specify a value for the Orientation parameter.
The ordinal number of the object that you are referring to, starting with 1 for the first object.
UFT counts the text objects that match the Text parameter, in the direction specified in the Orientation parameter.

Return Type

An AITextObject object.

Example

Back to top

 

FindTextBlock Property

Description

Creates an AITextObject Object for the specified text block.

If there are multiple similar objects on one page in the application, use the object's relative location in the application to describe it uniquely.

Syntax

object.FindTextBlock Text, [Orientation], [Occurrence]

Arguments

Parameter Description
Text

Required. A String value.
The text block to find.

Orientation

Optional. A predefined constant or string value. Mandatory if you specify a value for the Occurrence parameter.
The direction in which to count when referring to an object's location in the application.
Possible values: 
Strings: "FromTop""FromLeft", "FromRight", "FromBottom".
Constant values: micFromTopmicFromLeft, micFromRight, micFromBottom.

Occurrence

Optional. An Integer value. Mandatory if you specify a value for the Orientation parameter.
The ordinal number of the object that you are referring to, starting with 1 for the first object.
UFT counts the text objects that match the Text parameter, in the direction specified in the Orientation parameter.

Return Type

An AITextObject Object.

Example

Back to top

SetContext Method

Description

Sets the top-level object in which to use AI.

Always set the AI context before using any AI operations.

Syntax

object.SetContext AIContext

Arguments

Parameter Description
AIContext Required. An IDispatch value. A top-level test object.
The top-level test object to use for the context.

Return Type

None.

IMPORTANT

Only a mobile Device test object that exists in your object repository can currently be used as an AI context.

Example

Back to top