TextObject Object
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 One 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 One (Tools > Options > GUI Testing tab > Text Recognition).
Tip: You can test HTML5 Canvas in UFT One 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, checkpoint and output value steps, and as argument values for the GetTOProperty and GetROProperty methods.
Methods
CaptureBitmap | Saves a screen capture of the object as a .png or .bmp image, depending on the specified file extension. |
CheckProperty | Checks whether the specified object property achieves the specified value within the specified timeout. |
Click | Clicks the object. |
ClickSpecial | Clicks the object, without first bringing its parent into focus. |
DblClick | Double-clicks the object. |
Drag | Performs the 'drag' part of a drag and drop operation. |
Drop | Performs the 'drop' part of a drag and drop operation. |
GetAllROProperties | Returns the collection of properties and current values from the object in the application. |
GetROProperty | Returns the current value of the specified description property from the object in the application. |
GetTOProperties | Returns the collection of properties and values used to identify the object. |
GetTOProperty | Returns the value of the specified description property from the test object description. |
Highlight | Highlights the object in the application. |
Hover | Places the pointer on the object. |
LongClick | Presses and holds the left mouse button for a specific number of seconds. |
MouseDown | Presses the mouse button. |
MouseMove | Moves the mouse pointer to the object. |
MouseUp | Releases the mouse button. |
Output | Retrieves the current value of an item and stores it in a specified location. |
RefreshObject | Instructs UFT One to re-identify the object in the application the next time a step refers to this object. |
SetTOProperty | Sets the value of the specified description property in the test object description. |
ToString | Returns a string that represents the current test object. |
Type | Types the specified string in the object. |
TypeSecure | Types the encrypted value in the object. |
WaitProperty | Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step. |
Properties
Exist | Checks whether the object currently exists in the open application. |
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.
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 One 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
'The following example uses the Click method to perform a middle-button click 'on the "Contact Us" text on the GOBAR website, at a specific location in the text Set MyTextObj = Description.Create() MyTextObj("MicClass").Value ="TextObject" MyTextObj("text").Value ="ContactUs" Browser("GOBAR").TextObject(MyTextObj).Click(10, 5, micMiddleBtn)
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.
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
'The following example uses the ClickSpecial method to click the text 'Click Me' 'when it appears on the web page.The ClickSpecial method does not 'refresh the parent object, and the text remains visible. Set MyTextObj = Description.Create() MyTextObj("MicClass").Value ="TextObject" MyTextObj("text").Value ="Click Me" Browser("GOBAR").TextObject(MyTextObj).ClickSpecial
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
'The following example uses the DblClick method to perform a left-button double- 'click on the "Contact Us" text on the GOBAR website, at a specific location on the text Set MyTextObj = Description.Create() MyTextObj("MicClass").Value ="TextObject" MyTextObj("text").Value ="Contact Us" Browser("GOBAR").TextObject(MyTextObj).DblClick(40, 2, micLeftBtn)
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
'The following example uses the Drag method to drag the "Communities" 'control on the GOBAR website from coordinates 10,5, and then uses the Drop method 'to drop it at coordinates (100,-20). Set MyTextObj = Description.Create() MyTextObj("MicClass").Value ="TextObject" MyTextObj("text").Value ="Communities" Browser("GOBAR").TextObject(MyTextObj).Drag(10, 5) Browser("GOBAR").TextObject(MyTextObj).Drop(100, -20)
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
'The following example uses the Drag method to drag the "Communities" 'control on the GOBAR website from coordinates 10,5, and then uses the Drop method 'to drop it at coordinates (100,-20). Set MyTextObj = Description.Create() MyTextObj("MicClass").Value ="TextObject" MyTextObj("text").Value ="Communities" Browser("GOBAR").TextObject(MyTextObj).Drag(10, 5) Browser("GOBAR").TextObject(MyTextObj).Drop(100, -20)
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
'The following example uses the Hover method to open the first "Connect" menu 'on the GOBAR website, holding the mouse over the point 2,6 from the upper left corner of the text. Set MyTextObj = Description.Create() MyTextObj("MicClass").Value ="TextObject" MyTextObj("text").Value ="Connect" MyTextObj("text_index").Value =0 Browser("GOBAR").TextObject(MyTextObj).Hover(2, 6)
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 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
'The following example uses the LongClick method to select the word 'Encyclopedia, the third time it appears in the block of text, by holding it for 1.5 seconds. Set MyTextObj = Description.Create() MyTextObj("MicClass").Value ="TextObject" MyTextObj("text").Value ="Encyclopedia" MyTextObj("text_index").Value =2 Browser("GOBAR").TextObject(MyTextObj).LongClick(1.5)
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.
Default value = -9999 |
Button |
Optional. A predefined constant or number. The mouse button to press. Default value = micLeftBtn |
Return Type
None
Example
'The following example uses the MouseMove, MouseDown, and MouseUp methods 'to click the second 'Run' button in a browser app (text_index starts from 0). Set MyTextObj = Description.Create() MyTextObj("MicClass").Value = "TextObject" MyTextObj("text").Value = "Run" MyTextObj("text_index").Value = 1 Browser("SomeSite").TextObject(MyTextObj).MouseMove Browser("SomeSite").TextObject(MyTextObj).MouseDown Browser("SomeSite").TextObject(MyTextObj).MouseUp
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
'The following example uses the MouseMove, MouseDown, and MouseUp methods 'to click the first 'Run' button in a browser app (text_index starts from 0). Set MyTextObj = Description.Create() MyTextObj("MicClass").Value ="TextObject" MyTextObj("text").Value ="Run" MyTextObj("text_index").Value =1 Browser("SomeSite").TextObject(MyTextObj).MouseMove Browser("SomeSite").TextObject(MyTextObj).MouseDown Browser("SomeSite").TextObject(MyTextObj).MouseUp
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.
Default value = -9999 |
Button |
Optional. A predefined constant or number. The mouse button to release. Default value = micLeftBtn |
Return Type
None
Example
'The following example uses the MouseMove, MouseDown, and MouseUp methods 'to click the first 'Run' button in a browser app (text_index starts from 0). Set MyTextObj = Description.Create() MyTextObj("MicClass").Value = "TextObject" MyTextObj("text").Value = "Run" MyTextObj("text_index").Value = 1 Browser("SomeSite").TextObject(MyTextObj).MouseMove Browser("SomeSite").TextObject(MyTextObj).MouseDown Browser("SomeSite").TextObject(MyTextObj).MouseUp
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: 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
'The following example uses the Type method to first click the "Contact Us" ' text on the GOBAR website, and then type "Hi there" in the control. Set MyTextObj = Description.Create() MyTextObj("MicClass").Value ="TextObject" MyTextObj("text").Value ="Contact Us" Browser("GOBAR").TextObject(MyTextObj).Type("Hi there") 'The following example uses the Type method to type "Hello" in the '"Contact Us" text on the GOBAR website, without clicking the 'control before typing. Set MyTextObj = Description.Create() MyTextObj("MicClass").Value ="TextObject" MyTextObj("text").Value ="Contact Us" Browser("GOBAR").TextObject(MyTextObj).Type("Hello", False)
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: 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, do one of the following:
Use the Password Encoder utility (available from the Windows Start menu).
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 UFT One Help Center.
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
'The following example uses the Type method to type a user name in the ' first "User name" field and then the TypeSecure method to type an encrypted password ' in the first "Password" field on the GOBAR website. ' Each field is clicked before the typing operation is performed. Set MyTextObj_User = Description.Create() MyTextObj_User("MicClass").Value ="TextObject" MyTextObj_User("text").Value ="User name" MyTextObj_User("text_index").Value =0 Set MyTextObj_Password = Description.Create() MyTextObj_Password("MicClass").Value ="TextObject" MyTextObj_Password("text").Value ="Password" MyTextObj_Password("text_index").Value =0 Browser("GOBAR").TextObject(MyTextObj_User).Type("My Name") Browser("GOBAR").TextObject(MyTextObj_Password).TypeSecure("424fe79992c06f8f77dd04e9cc8c73194a60")