AIRegex Object
Description
AIRegex is a class that creates an AIRegexObj. The AIRegexObj object contains a regular expression, which provides a text pattern.
Use this object when describing text for AI-based object identification. This enables you to describe the AI-based object using a text pattern the text should match, rather than exact text.
IMPORTANT
AI-based testing is supported on the following technologies:
Web, mobile, and SAP GUI for Windows.
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.
Use AIRegex in the AIText parameter of the AIUtil.AIObject or AIUtil.FindTextBlock properties that create an AIObject.
Operations
The sections below list the built-in methods and properties that you can use as operations for the AIRegex class and the AIRegexObj object.
Properties
AIRegex.CreateRegexObj | Creates the AIRegexObj Object, which has the Pattern property.
|
AIRegexObj.Pattern | The regular expression represented by this AIRegexObj object. |
CreateRegexObj Property
Description
Creates an AIRegexObj object containing the specified regular expression.
Syntax
This is the default property of the AIRegex class, and can therefore be omitted from the syntax.
One of:
AIRegex.CreateRegexObj (Pattern)
AIRegex (Pattern)
Arguments
Parameter | Description |
---|---|
Pattern |
Required. A String value. For details about using regular expressions in AI-based testing, see the UFT One Help Center. |
Return Type
An AIRegexObj object.
Example
'The following example creates a regular expression that describes a US Dollar price 'Then, the example uses this regular expression to describe the price in the shopping cart AIUtil.SetContext Browser("creationtime:=0") 'Set the context for AI Set regex=AIRegex("Subtotal \(\d item\): \$[\d.]+") 'Next, the example clicks the first place this price appears on the page AIUtil.FindTextBlock(regex, micFromTop, 1).Click AIUtil("button", regex).click 'Click the button with the price label
Pattern Property
Description
Returns the regular expression represented by this AIRegexObj object.
Syntax
object.Pattern
Return Type
A String
Example
'The following example prints the pattern contained in the AIRegexObj object AIUtil.SetContext Device("device") 'Set the context for AI Set regex=AIRegex("\$[\d.]+") print regex.Pattern
See also: