AITable Object
This object is supported as a technical preview.
Description
An internal object used to perform operations on a grid object identified using AI.
AITable objects are containers. You can access the specific controls inside the AITable container and perform operations directly on them.
IMPORTANT
AITables are supported on the following technologies:
Web and SAP GUI for Windows.
AI objects are supported in UFT One only when:
- The UFT One Web Add-in or SAP Solutions Add-in is installed and loaded.
- The UFT One AI Features are installed and AI is enabled in the UFT One options. For details, see the UFT One Help Center.
To retrieve an AITable object, use the AIUtil.Table property.
Note: Table cell objects are identified using ABBYY OCR. To create AITableCell objects or to use the row or column count operations, you must have the ABBYY OCR Engine feature installed in UFT One.
Operations
The sections below list the built-in methods and properties that you can use as operations for the AITable object.
Note: You can also view a list and descriptions of the AITable properties that you can retrieve using the GetObjectProperty and GetAllProperties methods. You can then use the properties to check the object's location or content.
Methods
CaptureBitmap | Saves a screen capture of the object as a .png or .bmp image using the specified file name. |
CheckExists | A checkpoint that checks whether the object currently exists in the set context. |
GetAllProperties | Retrieves all of the AITable's properties and their values from the application. |
GetObjectProperty | Retrieves the value of the specified object property from the table in the application. |
Highlight | Highlights the object in the application. |
VisibleColumnCount | Returns the number of visible columns in the table. |
VisibleRowCount | Returns the number of visible rows in the table. |
Properties
AIObject | Creates an AIObject for the specified control found inside the container. |
Cell | Creates an AITableCell object for the specified table cell. |
Exist | Checks whether the object currently exists in the set context. |
FindText | Creates an AITextObject for the specified text found inside the container. |
FindTextBlock | Creates an AITextObject for the specified text block found inside the container. |
CaptureBitmap Method
Description
Saves a screen capture of the object as a .png or .bmp image using the specified file name.
Syntax
AIUtil.Table([locator], [locatorData]).CaptureBitmap FullFileName, [OverrideExisting]
Arguments
Parameter | Description |
---|---|
FullFileName | Required. A String value. The path to the file to store the screen capture. The file extension indicates whether to save the capture as a .png or .bmp file. |
OverrideExisting | Optional. A Boolean value. Indicates what to do if a file by the specified name already exists: True: Replace the existing file with the new capture. False (Default): The step fails if a file by the specified name already exists. |
Return Type
None
Examples
'The following example uses the CaptureBitmap method to capture an image of a table
' currently open in the browser.
AIUtil.SetContext Browser("creationtime:=0")
AIUtil.Table(micFromTop, 2).CaptureBitmap "c:\table.bmp"
CheckExists Method
Description
A checkpoint that checks whether the object currently exists in the set context.
Syntax
AIUtil.Table([locator], [locatorData]).CheckExists expected
Arguments
Parameter | Description |
---|---|
expected | A Boolean value. Specifies whether this checkpoint expects the object to exist. Possible values: true. The checkpoint passes if the object is found within the set context before the timeout expires. false. The checkpoint passes if the object is not found by the time the timeout expires. |
Remarks
This method uses the timeout defined in the Object Synchronization Timeout option in the Run pane of the Test Settings dialog box.
UFT One directly performs this method without verifying object identification even if you enable it in Options > GUI Testing > AI or use the AIUtil.RunSettings.VerifyIdentification.Enable step.
Return Type
A Boolean value.
Returns TRUE if the checkpoint passes, otherwise FALSE.
A TRUE return value reports a Passed step to the run results; a FALSE return value reports a Failed step to the run results.
Example
'This function clicks a button that opens a table and then makes sure the table exists
AIUtil.SetContext Browser ("title:=.*")
AIUtil("button", "Open table").Click
AIUtil.Table(micFromTop, 3).CheckExists True
objExist = AIUtil.Table(micFromTop, 3).Exist
if(objExist) then
Print("Table exists"
End If
GetAllProperties Method
Description
Retrieves all of the AITable's properties and their values from the application.
Syntax
AIUtil.Table([locator], [locatorData]).GetAllProperties
Return Type
A Dictionary object
Example
'The following example retrieves the properties of an AITable and prints them.
AIUtil.SetContext Browser("creationtime:=0") 'Set the context for AI
Set properties = AIUtil.Table(micFromTop, 3).GetAllProperties
For i = 0 To properties.count - 1
print properties.keys()(i) & ":" & properties(properties.keys()(i))
Next
'Print just one of the retrieved properties.
print "height:'" & properties("height") & "'"
GetObjectProperty Method
Description
Retrieves the value of the specified object property from the table in the application.
Syntax
AIUtil.Table([locator], [locatorData]).GetObjectProperty (property)
Arguments
Parameter | Description |
---|---|
property | Required. A String. The name of the property whose value to return. |
Return Type
A Variant.
Example
'The following example retrieves the height property of an AITable and prints it.
AIUtil.SetContext Browser("creationtime:=0") 'Set the context for AI
print "height:'" & AIUtil.Table(micFromTop, 3).GetObjectProperty ("height") & "'"
Highlight Method
Description
Highlights the object in the application.
Syntax
AIUtil.Table([locator], [locatorData]).Highlight
Return Type
None
Example
'The following example draws a rectangle that flashes for a second around the identified table
AIUtil.SetContext Browser("MyBrowser") 'Set the context for AI
AIUtil.Table(micFromRight, 2).Highlight
VisibleColumnCount Method
Description
Returns the number of visible columns in the table.
Syntax
AIUtil.Table([locator], [locatorData]).VisibleColumnCount
Return Type
An Integer
Example
rows = AIUtil.Table.VisibleRowCount
columns = AIUtil.Table.VisibleColumnCount
For row = 0 To rows - 1
For column = 0 To columns - 1
If AIUtil.Table.Cell(row, column).GetText() = "UFT One" Then
Print "Found at " & row & ", " & column
End If
Next
Next
VisibleRowCount Method
Description
Returns the number of visible rows in the table.
Syntax
AIUtil.Table([locator], [locatorData]).VisibleRowCount
Return Type
An Integer
Example
rows = AIUtil.Table.VisibleRowCount
columns = AIUtil.Table.VisibleColumnCount
For row = 0 To rows - 1
For column = 0 To columns - 1
If AIUtil.Table.Cell(row, column).GetText() = "UFT One" Then
Print "Found at " & row & ", " & column
End If
Next
Next
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 in the container, use the object's relative location in the container to describe it uniquely.
Syntax
AIUtil.Table([locator], [locatorData]).AIObject ControlType, [AIText], [locator], [locatorData]
Arguments
Parameter | Description |
---|---|
ControlType |
Required. A String value. The type of the control. For a list of supported control types, see the UFT One Help Center. |
AIText |
Optional. A String value. |
locator | Optional. A predefined constant or string value. Mandatory if you specify a value for the locatorData parameter. Used to describe the unique location of an object that may appear multiple times in the container. The location can be ordinal, relative to similar objects in the container, or proximal, relative to a different AI object, considered an anchor.
|
locatorData | Optional. An Integer value or an AI object. Mandatory if you specify a value for the locator parameter.
|
Return Type
An AIObject Object.
Example
'The following example clicks a menu in a table on a web page and then types a user name 'in the appropriate field in the table. Both controls are identified using AI. ' Next, the example clicks the second button from the left within the table. AIUtil.SetContext Browser("MyBrowser") 'Set the context for AI AIUtil.Table.AIObject("hamburger_menu").click AIUtil.Table.AIObject("input", "USER NAME").Type "admin" AIUtil.Table.AIObject("button", micAnyText, "FromLeft", 2).click
Cell Property
Description
Creates an AITableCell object for the specified table cell.
Syntax
AIUtil.Table([locator], [locatorData]).Cell Row, Column
Arguments
Parameter | Description |
---|---|
Row | Required. A String or numeric value. The cell's row name or index. Note: The text in leftmost column is considered the row name. |
Column | Required. A String or numeric value. The cell's column name or index. Note: If the table has no column header, the text in the topmost row is considered the column name. |
Return Type
Example
'The following example locates a check box in a specific table cell and draws a flashing rectangle around it
AIUtil.SetContext Browser("MyBrowser") 'Set the context for AI
AIUtil.Table.Cell(2, "Status").AIObject("check box").Highlight
Exist Property
Description
Checks whether the object currently exists in the set context.
Syntax
AIUtil.Table([locator], [locatorData]).Exist([TimeOut])
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.
Note: A value of 0 is not supported for Mobile test objects. For more information on the Object Synchronization Timeout, see the UFT One Help Center. |
Return Type
A Boolean value indicating whether the object exists.
Remarks
The Exist property can only be used in statements that use its return value. For example, assignment, print, and if statements.
UFT One directly performs this method without verifying object identification even if you enable it in Options > GUI Testing > AI or use the AIUtil.RunSettings.VerifyIdentification.Enable step.
Example
'This function clicks a button that opens a table and then makes sure the table exists
AIUtil.SetContext Browser ("title:=.*")
AIUtil("button", "Open table").Click
AIUtil.Table(micFromTop, 3).CheckExists True
objExist = AIUtil.Table(micFromTop, 3).Exist
if(objExist) then
Print("Table exists"
End If
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 in the container, use the object's relative location in the container to describe it uniquely.
Syntax
AIUtil.Table([locator], [locatorData]).FindText AIText, [locator], [locatorData]
Arguments
Parameter | Description |
---|---|
AIText |
Required. A String value. Enter the micAnyText constant if you want to ignore this parameter and provide values for locator and locatorData. This is useful when you want to identify an object by its location and later retrieve the text from the object. |
locator | Optional. A predefined constant or string value. Mandatory if you specify a value for the locatorData parameter. Used to describe the unique location of an object that may appear multiple times in the container. The location can be ordinal, relative to similar objects in the container, or proximal, relative to a different AI object, considered an anchor.
|
locatorData | Optional. An Integer value or an AI object. Mandatory if you specify a value for the locator parameter.
|
Return Type
Example
'The following example checks that the table does not display an error
AIUtil.SetContext Browser ("title:=.*")
AIUtil.Table.FindText("error").CheckExists "False"
FindTextBlock Property
Description
Creates an AITextObject Object for the specified text block.
If there are multiple similar objects in the container, use the object's relative location in the container to describe it uniquely.
Syntax
AIUtil.Table([locator], [locatorData]).FindTextBlock AIText, [locator], [locatorData]
Arguments
Parameter | Description |
---|---|
AIText |
Required. A String value. Enter the micAnyText constant if you want to ignore this parameter and provide values for locator and locatorData. This is useful when you want to identify an object by its location and later retrieve the text from the object. |
locator | Optional. A predefined constant or string value. Mandatory if you specify a value for the locatorData parameter. Used to describe the unique location of an object that may appear multiple times in the container. The location can be ordinal, relative to similar objects in the container, or proximal, relative to a different AI object, considered an anchor.
|
locatorData | Optional. An Integer value or an AI object. Mandatory if you specify a value for the locator parameter.
|
Return Type
Example
'The following example checks that "Good day" is displayed in the table
AIUtil.SetContext Browser ("title:=.*")
AIUtil.Table(micFromTop, 3).FindTextBlock("Good day").CheckExists "True"
See also: