AIObject Object

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.

Description

An internal object used to perform operations on an object recognized using AI.

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

IMPORTANT

To retrieve an AIObject object, use the AIUtil.AIObject default property.

Operations

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

Method Click Clicks the object.
Method Exist Checks whether the object currently exists in the set context.
Method Highlight

Highlights the object in the application.

Method Hover

Holds the cursor over the object.

Supported in UFT versions 15.0.1 and later.

Method Search

Performs a search operation using an AIObject of type “Search”.

Method Select

Selects an item from a combo box.

Supported in UFT versions 15.0.1 and later.

Method SetState Sets the state of a check box or toggle button to On or Off.
Method Type Types the specified string in the object.
Method TypeSecure Types the specified encrypted string in the object.

Back to top

 

Click Method

Description

Clicks the object.

Syntax

AIUtil.AIObject(ControlType, [text]).Click  [x], [y]

or

AIUtil(ControlType, [text]).Click [x], [y]

Note: You can omit the AIObject property in the syntax, because AIObject is the default property for the AIUtil object.

Arguments

Parameter Description
x Optional. An integer value.
The x-coordinate of the click. Note that the specified coordinates are relative to the upper left corner of the object.  The default value is the middle of the object (-9999).
y Optional. An integer value.
The y-coordinate of the click. Note that the specified coordinates are relative to the upper left corner of the object.  The default value is the middle of the object (-9999).

Return Type

None

Example

Back to top

 

Exist Method

Description

Checks whether the object currently exists in the set context.

Syntax

AIUtil.AIObject(ControlType, [text]).Exist ([TimeOut])

or

AIUtil(ControlType, [text]).Exist ([TimeOut])

Note: You can omit the AIObject property in the syntax, because AIObject is the default property for the AIUtil object.

Arguments

Parameter Description
TimeOut

Optional. An unsigned long integer value.

The length of time (in seconds) to search for the object before returning a True or False value.

  • If a timeout value is specified, UFT waits until it finds the object or until the timeout is reached.

  • If no value is specified, the value specified in the Test Settings dialog box for the Object Synchronization Timeout is used for tests. For business components, the pre-defined value of 20 seconds is used.

Note: A value of 0 is not supported for Mobile test objects.

For more information on the Object Synchronization Timeout, see the Unified Functional Testing User Guide.

Return Type

A Boolean value indicating whether the object exists.

Example

Back to top

 

Highlight Method

Description

Highlights the object in the application.

Syntax

AIUtil.AIObject(ControlType, [text]).Highlight

or

AIUtil(ControlType, [text]).Highlight

Note: You can omit the AIObject property in the syntax, because AIObject is the default property for the AIUtil object.

Return Type

None

Example

Back to top

Hover Method

Supported in UFT versions 15.0.1 and later.

Description

Holds the cursor over the object.

Syntax

AIUtil.AIObject(ControlType, [text]).Hover [duration]

or

AIUtil(ControlType, [text]).Hover [duration]

Note: You can omit the AIObject property in the syntax, because AIObject is the default property for the AIUtil object.

Arguments

Parameter Description
duration Optional. A Variant.

The time period (in seconds) to hold the cursor over the object.

You can specify partial seconds as a duration time.

Default: 2 seconds.

Return Type

None

IMPORTANT

This method is supported only on Web applications running in a Web browser on a Desktop computer and not on mobile devices.

Before a Hover step, use the AIUtil.IsMobileContext to make sure the current AI context is a desktop web browser.

Designing your test this way makes it easier to use the same test for your web application on various platforms.

Example

Back to top

Search Method

Description

Performs a search operation using an AIObject of type “Search”.

Syntax

AIUtil.AIObject("Search").Search  [text]

or

AIUtil("Search").Search [text]

Note: You can omit the AIObject property in the syntax, because AIObject is the default property for the AIUtil object.

Arguments

Parameter Description
text Required. A String value.
The string to enter in the search box.

Return Type

None

IMPORTANT

The Search method is supported only for AIObjects of type "Search". The method enters the specified string in the search box and presses Enter.

Example

Back to top

Select Method

Supported in UFT versions 15.0.1 and later.

Description

Selects an item from a combo box.

Syntax

AIUtil.AIObject(ControlType, [text]).Select  Item

or

AIUtil(ControlType, [text]).Select Item

Note: You can omit the AIObject property in the syntax, because AIObject is the default property for the AIUtil object.

Arguments

Parameter Description
Item

Required. A String value.
The item to select.

Return Type

None.

IMPORTANT

This method is supported for ControlType combo box, only in cases where UFT can also identify this combo box as a WebList or a MobileDropDown.

Example

Back to top

SetState Method

Description

Sets the state of a check box or toggle button to On or Off.

Syntax

AIUtil.AIObject(ControlType, [text]).SetState  State

or

AIUtil(ControlType, [text]).SetState State

Note: You can omit the AIObject property in the syntax, because AIObject is the default property for the AIUtil object.

Arguments

Parameter Description
State

Required. A String value.
The state to set.

Possible values: On, Off (case-insensitive)

Return Type

None.

IMPORTANT

This method is supported for ControlType Toggle, Check box, and Radio button.

A radio button object represents one button in a radio group. Therefore, SetState on a radio button can only set the button to On. To set a radio button to Off, you must use SetState to set a different radio button in the group to On.

Example

Back to top

 

Type Method

Description

Types the specified string in the object.

Syntax

AIUtil.AIObject(ControlType, [text]).Type  [text]

or

AIUtil(ControlType, [text]).Type [text]

Note: You can omit the AIObject property in the syntax, because AIObject is the default property for the AIUtil object.

Arguments

Parameter Description
text Required. A String value.
The string to type.

Return Type

None

Example

Back to top

 

TypeSecure Method

Description

Types the specified encrypted string in the object.

Syntax

AIUtil.AIObject(ControlType, [text]).TypeSecure  [text]

or

AIUtil(ControlType, [text]).TypeSecure [text]

Note: You can omit the AIObject property in the syntax, because AIObject is the default property for the AIUtil object.

Arguments

Parameter Description
text Required. A String value.
The encrypted string to type.

Return Type

None

IMPORTANT

To find the encrypted value to use as the argument for the TypeSecure method, use the Password Encoder utility (Start > All Programs > Unified Functional Testing > Tools > Password Encoder) or parameterize the argument and use the Data Table encryption option (right-click each unencrypted value in the password column and choose Data > Encrypt). For more information, see the Unified Functional Testing Help.

Note: While the TypeSecure method enables you to hide passwords on the screen when running a test, it is not intended to be a secure way to protect password information.

Example

Back to top