Replace an exact-match property with a pattern

You can replace a recognition property with a regular expression or a numeric range to allow for a pattern-based recognition. The pattern allows for more flexibility in the object recognition. You can convert properties to regular expressions or numeric ranges from within both the Verification Point Editor and the object map.

You can undo any regular expression or numeric range. After you convert a value to a regular expression or numeric range, the shortcut menu then contains an Undo command, which you can use to return to the original value.

For information about the full syntax of the regular expressions, see the util.regex package in the API documentation. Click Help > Functional Test API Reference, and select com.rational.test.util.regex.


Related concepts

Regular Expression Evaluator

Verification Point Editor

Related tasks

Editing object properties

Add test object descriptions

Create properties verification point

Related reference

Regular expression examples

Verification Point Editor

Test object maps


To use a regular expression from the test object map:


Procedure

  1. Select the object in the test object map or in the Unification wizard.

  2. In the Recognition Property grid in the map or in the top pane of the Unification wizard, right-click the value to change and select Convert Value to Regular Expression.

    The value is designated as a regular expression by the blue in front of the value text.

  3. Click another property in the grid, and then double-click the value so that you can edit the field.

    Alternatively, you can edit the expression in the Regular Expression Evaluator.

    To test your regular expression while you edit it, use the Regular Expression Evaluator. In step 3, right-click the expression, and click Evaluate Regular Expression. The Pattern and Match Against Value fields contain the current value. To try an expression, change the value in the Pattern field and click the Evaluate button. The Result indicates whether the expression matched.

  4. Edit the value. For example, if it is a text property of "customer" you might change it as follows:

    [cC]ustomer

    This syntax allows any text that contains the word "customer" with either an uppercase "C" or lowercase "c" will match. This is important because the comparisons are case-sensitive.

    You can change a case-insensitive comparison by using the Regular Expression Evaluator, or in the interface of the object map, Verification Point Editor, and Verification Point Comparator. In the Regular Expression Evaluator, you can set an option for case sensitivity. The Perform Case Sensitive Match option is on by default. Matching is case-sensitive. If you want matching to ignore case, clear this option. You can set case sensitivity in the interface of the object map or the Verification Point Editor and Comparator. In those tools, when you right-click on a regular expression value, you can click Case Sensitive Regular Expression. For examples of these options, see the Case sensitivity example in Regular Expression Examples topic.

  5. Click outside that cell again.

    You are finished if you were in the test object map. If you used the Unification Wizard in the map, click Next, and click Finish.

  6. Click Save in the object map.


Results

For more information, see the Test Object Map related topic.


Examples


About this task

For examples of regular expression syntax and use cases, see Regular Expression Examples related topic.

For information about the full syntax of the regular expressions, see the util.regex package in the API documentation.


To use a numeric range from the Verification Point Editor:


Procedure

  1. In the grid display for a Properties verification point in the Verification Point Editor, select a numeric value in the Value column.

  2. Right-click the value to change and click Convert Value to Numeric Range.

    The value is designated as a numeric range by the blue in front.


  3. If necessary, click the plus sign (+) next to the value to see lower, upper, and compareBounds properties.

    • Lower is the lower bounds of the range. Double-click the lower value to edit it. After you edit it, click outside the cell.

    • Upper is the upper bounds of the range. Double-click the upper value to edit it. After you edit it, click outside the cell.

    • Double-click the compareBounds value. Select the bounds you want to use from the list. Lower & Upper is the default.

      For example, if you want a lower bound of 2, an upper bound of 20, and to use lower & upper, the range is set as follows:

      Range[2 .. 20]

      Any number between 2 and 20, including 2 and 20, will pass.

      If you use the same numbers, but choose Lower instead of lower & upper in the compareBounds value, the range is set as follows:

      Range[2 .. 20>

      Any number between 2 and 20, including 2 but excluding 20, will pass.

  4. Click Save.


Results

For more information, see Verification Point Editor related topic.

Numeric ranges can be created from numbers and from strings in the form of integers or floats. You can convert properties to a numeric range in the test object map or in the Verification Point Editor and Verification Point Comparator. You can use a numeric range from both a Properties verification point and from all the types of Data verification points. The following section explains how to convert to a regular expression from the different verification point displays. Converting to a numeric range works the same way, except that you use the Convert Value to Numeric Range menu or button.


To use a regular expression from the Verification Point Editor


About this task

You can convert a value to a regular expression in every type of verification point. For Properties, Data (List), and Data (Table), you convert it from the Value field as described above for a numeric range. (Right-click the value you want to change and click Convert Value to Regular Expression.)

For a Data (Menu Hierarchy) verification point, double-click a menu item in the data pane to open a small grid editor. Right-click the value in the grid that you want to change and click Convert Value to Regular Expression. You can then edit it as described. Close the editing grid when you are finished.

For a Data (Tree Hierarchy) verification point, double-click a tree node in the data pane to open a small text editor. Click the Convert Value to Regular Expression button on the toolbar. You can then edit it in the text box. Close the editor when you are finished.

For a Data (Text) verification point, click Convert Value to Regular Expression on the toolbar in the data pane of the Verification Point Editor. All the text in the data pane is converted. You can then edit this text right in the data pane. This generally only works well for small amounts of text. If you want a text property, you could create a Properties verification point, and then convert the Text property value to a regular expression.