Relevant for: GUI tests and components and API testing
A regular expression is a string that specifies a complex search phrase. By using special characters, such as a period (.), asterisk (*), caret (^), and brackets ([ ]), you can define the conditions of a search.
Regular expressions are used to identify objects and text strings with varying values. You can use regular expressions to instruct UFT to find a value that matches a particular pattern or condition instead of a specific hard-coded value.
You can use regular expressions only for values of type string.
Suppose the name of a window's title bar changes according to a file name. You can use a regular expression in a test object description to identify a window whose title bar has the specified product name, followed by a hyphen, and then any other text. When the relevant step runs, UFT compares the regular expression that you provide with the corresponding value in your application.
Suppose the text property of an object is a date value, but the displayed date changes according to the current date. You can define a regular expression for the date, so that UFT can identify the object that contains text with the expected date format, rather than the exact date value.
Whenever a UFT feature supports regular expressions, the relevant dialog box includes a Regular Expression check box. Selecting this check box instructs UFT to treat the provided value as a regular expression. Some dialog boxes that contain a Regular Expression check box, also contain a right arrow adjacent to the text box for the value. Clicking this arrow enables you to select regular expression characters from a drop-down list, and to test your regular expression to make sure it suits your needs.
For example, there are a number of scenarios in which you could use regular expressions for a GUI test or component:
Defining the property values of an object in dialog boxes or in programmatic descriptions used within a function library
Defining expected values for checkpoints in tests
Defining pop-up window conditions in a recovery scenario
When defining XML checkpoint property values where the property is a string
HTTP Request test step checkpoint values, if the HTTP response is text
For details on defining regular expressions, including regular expression syntax, see Regular expression characters and usage options.
To see a demonstration of this functionality, go to the UFT Apps Marketpace page and select the Regular Expressions video.