AIRunSettings Object
Description
An object containing the settings for the current test run. These settings enable you to modify test settings during the test run, overriding the global settings defined in Tools > Options > GUI Testing > AI.
IMPORTANT
AI-based testing is supported on the following technologies:
UFT One versions 2022 and later: Web, mobile, and SAP GUI for Windows.
UFT One versions 2021 R1 and earlier: Web and mobile.
AI objects are supported in UFT One only when:
- The UFT One Web Add-in, Mobile 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 AIRunSettings object, use the AIUtil.RunSettings property.
The settings in an AIRunSettings object are arranged in child objects, each for a different type of settings. Use the relevant object property to retrieve the child settings objects.
Properties
The following table lists the built-in properties that you can use to access the settings child objects.
UFT One 2022 or later | Indicates whether the AI Service is accessed locally or remotely. Syntax AIUtil.RunSettings.AIServiceMode |
AutoScroll | Returns the AIRunSettingsAutoScroll object to use for the current test run. Syntax AIUtil.RunSettings.AutoScroll |
UFT One 2023 or later | Returns the AIRunSettingsComboBoxSelect object to use for the current test run. Syntax AIUtil.RunSettings.ComboBoxSelect |
OCR | Returns the AIRunSettingsOCR object to use for the current test run. Syntax AIUtil.RunSettings.OCR |
VerifyIdentification | Returns the AIRunSettingsVerifyIdentification object to use for the current test run. Syntax AlUtil.RunSettings.VerifyIdentification |
TextMatch | A String value. Specifies whether to look for the specified text exactly when identifying AI test objects, or use AI algorithms to find similar text as well. |
AIServiceMode Property
Supported in UFT One 2022 or later
Description
Indicates whether the AI Service is accessed locally or remotely
.
An Integer or predefined value.
Syntax
AIUtil.RunSettings.AIServiceMode
Possible values
0 or Local_AI. Use the local AI service. (Default)
1 or Remote_AI. Use a remote AI service.
'The following example checks whether we are using the local or remote AI service
'If local, instruct UFT One to use the UFT OCR settings for AI indentification
If AIUtil.RunSettings.AIServiceMode = Local_AI Then
AIUtil.RunSettings.Ocr.UseConfigSet = UFT_OCR
End If
Note: This statement is meant only to demonstrate code syntax. You can also use UFT_OCR if you are using the remote AI service.
AIRunSettingsAutoScroll Object
Description
Controls automatic scrolling for AI identification in the current test run.
By default, the automatic scrolling is on, and set to scroll down, up to 2 times.
Important
To retrieve an AIRunSettingsAutoScroll object, use the AIUtil.RunSettings.AutoScroll property.
Methods
The following table lists the methods you can call to control the run time AutoScroll settings:
'The following example scrolls down (based on the default settings) to highlight
' the SEE OFFER button, and then scrolls back up to highlight the SPEAKERS text
' Before changing the scroll direction, this example saves the original scroll settings
' and restores them after highlighting the required object
AIUtil.SetContext Browser("creationtime:=0")
Browser("creationtime:=0").Navigate "https://www.advantageonlineshopping.com"
AIUtil("button", "SEE OFFER").highlight
WasEnabled = AIUtil.RunSettings.AutoScroll.IsEnabled
OrigDirection = AIUtil.RunSettings.AutoScroll.GetDirection
OrigMax = AIUtil.RunSettings.AutoScroll.GetMaxNumberOfScrolls
AIUtil.RunSettings.AutoScroll.Enable "up", 2
AIUtil.FindTextBlock("SPEAKERS").highlight
If WasEnabled Then
AIUtil.RunSettings.AutoScroll.Enable OrigDirection, OrigMax
Else
AIUtil.RunSettings.AutoScroll.Disable
End If
AIRunSettingsComboBoxSelect Object
Supported on UFT One versions 2023 and later.
Description
Controls a combo box's AI-based Select operation.
By default, when looking for the item to select in a combo box's list, UFT One is set to scroll down, up to 10 times.
Important
To retrieve an AIRunSettingsComboBoxSelect object, use the AIUtil.RunSettings.ComboBoxSelect property.
The AI-based Select operation is supported only on non-mobile applications, and is used when the combo box is not identified as a WebList.
Properties
The following table lists the properties that represent the run time ComboBoxSelect settings:
'Select an item far down the list, then change the next Select
'to scroll up for an item at the top, scrolling up to 5 times,
'each scroll spanning 2 mouse-wheel ticks
AIUtil.SetContext Browser("creationtime:=0")
AIUtil("combo_box", "books").Select "Zenith"
AIUtil.RunSettings.ComboBoxSelect.ScrollingDirection = "up"
AIUtil.RunSettings.ComboBoxSelect.TicksPerScroll = 2
AIUtil.RunSettings.ComboBoxSelect.MaxScrollNum = 5
AIUtil("combo_box", "books").Select "ABC"
AIRunSettingsOCR Object
Description
Specifies the OCR settings to use in the current test run.
By default, only English text is identified.
Important
To retrieve an AIRunSettingsOCR object, use the AIUtil.RunSettings.OCR property.
Properties
The following table lists the properties that represent the run time OCR settings:
'If the OCR settings in use are the AI OCR settings, this example
'changes the settings for this run, to detect both English and French texts when using OCR.
If AIUtil.RunSettings.OCR.GetConfigSet = AI_OCR Then
AIUtil.RunSettings.Ocr.Languages="en, fr"
End If
AIUtil.FindTextBlock("Se connecter en toute sécurité").Click
AIRunSettingsVerifyIdentification Object
Description
Controls whether to verify the AI identification before performing the operation in the current test run.
Important
To retrieve an AIRunSettingsVerifyIdentification object, use the AlUtil.RunSettings.VerifyIdentification property.
Methods
The following table lists the methods you can call to control the identification verification settings:
'This examples instructs UFT One to double check if the ADD TO CART text block exists
'before clicking on the text.
'The example saves the original run setting and restores it after
' clicking the required text.
WasEnabled =AIUtil.RunSettings.VerifyIdentification.IsEnabled
AIUtil.RunSettings.VerifyIdentification.Enable
AIUtil.FindTextBlock("ADD TO CART").Click
If Not WasEnabled Then
AIUtil.RunSettings.VerifyIdentification.Disable
End If
TextMatch Property
Description
Specifies whether to look for the specified text exactly when identifying AI test objects, or use AI algorithms to find similar text as well.
Syntax
AIUtil.RunSettings.TextMatch
Possible values: micExactMatch, micAIMatch
Remarks
- By default, AI algorithms are used for text matching. If you set this property to micExactMatch in a test run, we recommend limiting it to specific steps and then setting back to micAIMatch.
- When using regular expression matching with micAIMatch, a certain level of deviation from the specified text pattern is accepted. For example, the pattern "Subtotal \(\d item\): \$[\d.]+" will pick up the price string even if it says "items" in plural or "Subt0tal" with a '0' instead of an 'o'.
- Exact match is case-insensitive.
'The following example instructs UFT to look for an exact match for "username"
' when identifying a text box using AI. Then it instructs UFT to go back to AI text recognition
AIUtil.RunSettings.TextMatch = micExactMatch
AIUtil("text_box", "username").Type "test"
AIUtil.RunSettings.TextMatch = micAIMatch
See also: