TextObject Object

Tech preview. Supported in UFT versions 15.0.1 and later.

Description

An object identified using OCR (Optical Character Recognition).

IMPORTANT

Use descriptive programming to describe TextObject test objects. You cannot spy on them, record them, or add them to the object repository.

A TextObject cannot be a top-level test object. UFT searches for the TextObject in the application within the parent object specified in its definition. Any object that supports the CaptureBitmap method can be the parent of a TextObject test object.

The OCR engine used for TextObject objects is determined by the Text Recognition options configured in UFT (Tools > Options > GUI Testing tab > Text Recognition).

Tip: You can test HTML5 Canvas in UFT by using TextObject objects.

Operations

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

Note: You can also view a list and descriptions of the TextObject description properties, for use in programmatic descriptions.

Methods

Method Click Clicks the object.
Method ClickSpecial Clicks the object, without first bringing its parent into focus.
Method DblClick Double-clicks the object.
Method Drag Performs the 'drag' part of a drag and drop operation.
Method Drop Performs the 'drop' part of a drag and drop operation.
Method Hover Places the pointer on the object.
Method LongClick Presses and holds the left mouse button for a specific number of seconds.
Method MouseDown Presses the mouse button.
Method MouseMove Moves the mouse pointer to the object.
Method MouseUp Releases the mouse button.
Method Type Types the specified string in the object.
Method TypeSecure Types the encrypted value in the object.

Back to top

 

Click Method

Description

Clicks the object.

Syntax

object.Click [x], [y], [Button]

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 text. 
Default value = -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 text. 


Tip: You can enter micNoCoordinate (-9999) for the x and y argument values if you want to enter a value for the button argument without specifying x- and y- coordinates for the click. micNoCoordinate indicates the center of the text.


Default value = -9999
Button Optional. A predefined constant or number.
The mouse button used to click the object.
Default value = micLeftBtn

Return Type

None

IMPORTANT

This method brings the TextObject’s parent test object into focus before performing the click. If this hides your TextObject in the application, making it impossible for UFT to find and click it, you can use the TextObject.ClickSpecial method, which does not bring the parent test object into focus before clicking. (Note: The parent test object that is brought into focus is the lowest-level parent that supports the MakeVisible method.)

Example

Back to top

 

ClickSpecial Method

Description

Clicks the object, without first bringing its parent into focus.

Syntax

object.ClickSpecial [x], [y], [Button]

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 text. 
Default value = -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 text. 


Tip: You can enter micNoCoordinate (-9999) for the x and y argument values if you want to enter a value for the button argument without specifying x- and y- coordinates for the click. micNoCoordinate indicates the center of the text.


Default value = -9999
Button Optional. A predefined constant or number.
The mouse button used to click the object.
Default value = micLeftBtn

Return Type

None

IMPORTANT

Use this method instead of the regular TextObject.Click method, if bringing the TextObject ’s parent test object into focus before performing the click hides your TextObject in the application.

Example

Back to top

 

DblClick Method

Description

Double-clicks the object.

Syntax

object.DblClick [x], [y], [Button]

Arguments

Parameter Description
x Optional. An integer value.
The x-coordinate of the double-click. Note that the specified coordinates are relative to the upper left corner of the text.
Default value = -9999
y Optional. An integer value.
The y-coordinate of the double-click. Note that the specified coordinates are relative to the upper left corner of the text.
Default value = -9999
Button Optional. A predefined constant or number.
The mouse button used to double-click the object.
Default value = micLeftBtn

Return Type

None

Example

Back to top

 

Drag Method

Description

Performs the 'drag' part of a drag and drop operation.

Syntax

object.Drag [x], [y], [Button]

Arguments

Parameter Description
x Optional. An integer value.
The x-coordinate within the window from which the object is dragged. Note that the specified coordinates are relative to the upper left corner of the text.
Default value = -9999
y Optional. An integer value.
The y-coordinate within the window from which the object is dragged. Note that the specified coordinates are relative to the upper left corner of the text.
Default value = -9999
Button Optional. A predefined constant or number.
The mouse button used to drag the object.
Default value = micLeftBtn

Return Type

None

Example

Back to top

 

Drop Method

Description

Performs the 'drop' part of a drag and drop operation.

Syntax

object.Drop [x], [y]

Arguments

Parameter Description
x Optional. An integer value.
The x-coordinate of the object onto which the object is dropped. Note that the specified coordinates are relative to the upper left corner of the text.
Default value = -9999
y Optional. An integer value.
The y-coordinate of the object onto which the object is dropped. Note that the specified coordinates are relative to the upper left corner of the text.
Default value = -9999

Return Type

None

Example

Back to top

 

Hover Method

Description

Places the pointer on the object.

Syntax

object.Hover [x], [y]

Arguments

Parameter Description
x Optional. An integer value.
The x-coordinate of the object that the pointer is placed over. Note that the specified coordinates are relative to the upper left corner of the text.
Default value = -9999
y Optional. An integer value.
The y-coordinate of the object that the pointer is placed over. Note that the specified coordinates are relative to the upper left corner of the text.
Default value = -9999

Return Type

None

IMPORTANT

The pointer remains placed over the object for the amount of time defined in the Windows hover settings.

Example

Back to top

 

LongClick Method

Description

Presses and holds the left mouse button for a specific number of seconds.

Syntax

object.LongClick [Duration], [x], [y]

Arguments

Parameter Description
Duration Optional. A double floating value.

The number of seconds to hold the left mouse button when long-clicking.
Default duration = 1.1 seconds


Default value = 1.10000002384186
x Optional. An integer value.
The x-coordinate of the object to be long-clicked. Note that the specified coordinates are relative to the upper left corner of the text.
Default value = -9999
y Optional. An integer value.
The y-coordinate of the object to be long-clicked. Note that the specified coordinates are relative to the upper left corner of the text.
Default value = -9999

Return Type

None

Example

Back to top

 

MouseDown Method

Description

Presses the mouse button.

Syntax

object.MouseDown [x], [y], [Button]

Arguments

Parameter Description
x Optional. An integer value.
The x-coordinate of the location to press. Note that the specified coordinates are relative to the upper left corner of the text. 
Default value = -9999
y Optional. An integer value.
The y-coordinate of the location to press. Note that the specified coordinates are relative to the upper left corner of the text. 


Tip: You can enter micNoCoordinate (-9999) for the x and y argument values if you want to enter a value for the button argument without specifying x- and y- coordinates for the press. micNoCoordinate indicates the center of the text.


Default value = -9999
Button Optional. A predefined constant or number.
The mouse button to press.
Default value = micLeftBtn

Return Type

None

Example

 

MouseMove Method

Description

Moves the mouse pointer to the object.

Syntax

object.MouseMove [x], [y]

Arguments

Parameter Description
x Optional. An integer value.
The x-coordinate of the location to place the mouse. Note that the specified coordinates are relative to the upper left corner of the text. 
Default value = -9999
y Optional. An integer value.
The y-coordinate of the location to place the mouse. Note that the specified coordinates are relative to the upper left corner of the text. 
Default value = -9999

Return Type

None

Example

 

MouseUp Method

Description

Releases the mouse button.

Syntax

object.MouseUp [x], [y], [Button]

Arguments

Parameter Description
x Optional. An integer value.
The x-coordinate of the location to release the mouse button. Note that the specified coordinates are relative to the upper left corner of the text. 
Default value = -9999
y Optional. An integer value.
The y-coordinate of the location to the location to release the mouse button. Note that the specified coordinates are relative to the upper left corner of the text. 


Tip: You can enter micNoCoordinate (-9999) for the x and y argument values if you want to enter a value for the button argument without specifying x- and y- coordinates for the release. micNoCoordinate indicates the center of the text.


Default value = -9999
Button Optional. A predefined constant or number.
The mouse button to release.
Default value = micLeftBtn

Return Type

None

Example

 

Type Method

Description

Types the specified string in the object.

Syntax

object.Type Text, [ClickBeforeType]

Arguments

Parameter Description
Text Required. A String value.
The text string to type in the object.
ClickBeforeType Optional. A Boolean value.
Specifies whether to click the object to bring it into focus before beginning the type operation.

Possible values:
True (default) - The object's center is clicked before typing.
False - The Type operation is performed at the current location of the cursor.

Tip: If you want to click a different location in the object before typing, add a step that calls the Click method before the step that calls the Type method. Specify the click coordinates in the Click step, and in the Type step, set the ClickBeforeType parameter to False.

Return Type

None

IMPORTANT

A TextObject might represent an object in your application on which a type operation is irrelevant, such as a button or a menu. If you run an TextObject.Type operation on such an object, the method has no affect.

Example

Back to top

 

TypeSecure Method

Description

Types the encrypted value in the object.

Syntax

object.TypeSecure Text, [ClickBeforeType]

Arguments

Parameter Description
Text Required. A String value.
The encrypted text to type in the object.
ClickBeforeType Optional. A Boolean value.
Specifies whether to click the object to bring it into focus before beginning the type operation.

Possible values:
True (default) - The object's center is clicked before typing.
False - The TypeSecure operation is performed at the current location of the cursor.

Tip: If you want to click a different location in the object before typing, add a step that calls the Click method before the step that calls the TypeSecure method. Specify the click coordinates in the Click step, and in the TypeSecure step, set the ClickBeforeType parameter to False.

Return Type

None

IMPORTANT

  • A TextObject might represent an object in your application on which a type operation is irrelevant, such as a button or a menu. If you run an TextObject.TypeSecure operation on such an object, the method has no affect.

  • 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