How To Use Regular Expression Evaluator in QTP 11
Regular Expression Evaluator |
To check how this utility works, we’ll try to identify two dialog boxes using the same object from the object repository. The titles of the dialog boxes are ‘QuickTest Pro 10.00 Version’ and ‘QuickTest Pro 11.00 Version’. In order to use the same object to identify both the dialog boxes, we will create a regular expression for dialog box title using ‘Regular Expression Evaluation’ utility. The two dialog boxes are shown below –
Dialog Boxes with Different Titles |
a) The first step is to add the initial dialog box in the object repository. Make sure that the ‘text’ property is being used to identify the object as shown below.
Repository with Dialog Box object |
QTP Repository Parameter |
Regular Expression Evaluator Window |
e) We need to generalize the version number (10.00 & 11.00) in the title of the dialog box so that the same title can recognize both the dialog boxes. If we replace the zero in ‘10‘ and one in ‘11‘ with a generic expression, QTP will be able to identify the title for both the dialog boxes. To do this, select the ‘0’ from ’10’ and click on the ‘right arrow’ button appearing before the Highlight button.
Regular Expression List |
f) Since we want to use the generic text that represents numbers, we will select ‘d Any digit’ from the regular expression list. Once the option is selected, the 0 from ’10’ will be replaced by ‘d’ in the regular expression field. Click on Highlight button to check that the regular expression highlights the entire sample text.
Highlighted Sample Text |
g) Since the sample text is highlighted, this means that the regular expression works correctly for the first dialog box. Let us check that the same regular expression will work for the other dialog box also. Enter ‘QuickTest Pro 11.00 Version’ in the Sample Text field below the original text. Again click on Highlight button. It will highlight both the texts which means that the same generic expression works for both the dialog boxes.
Generic Expression with 2 Matches |
To make sure that the regular expression is indeed working, close the ‘Regular Expression Evaluator’ window and highlight the object for both the dialog boxes from the object repository.
[This article only talks about how to use Regular Expression Evaluator utility to create and test regular expressions. Visit this page to learn more about regular expressions.]
If you enjoyed this article, you can join our blog to get free email updates directly in your inbox.