When to Use Regular Expressions - WinRunner

Use a regular expression when the name of a GUI object can vary each time you run a test. For example, you can use a regular expression for:

  • the physical description of an object in the GUI map
  • a GUI checkpoint, when evaluating the contents of an edit object or static text object with a varying name
  • a text checkpoint, to locate a varying text string using win_find_text or object_find_text

Using a Regular Expression in an Object’s Physical Description in the GUI Map

You can use a regular expression in the physical description of an object in the GUI map, so that WinRunner can ignore variations in the object’s label. For example, the physical description:

{
class: push_button
label: "!St.*"
}

enables WinRunner to identify a push button if its label toggles from “Start” to “Stop”.

Using a Regular Expression in a GUI Checkpoint

You can use a regular expression in a GUI checkpoint, when evaluating the contents of an edit object or a static text object with a varying name. You define the regular expression by creating a GUI checkpoint on the object in which you specify the checks. The example below illustrates how to use a regular expression if you choose Insert > GUI Checkpoint > For Object/Window and double-click a static text object. Note that you can also use a regular expression with the Insert > GUI Checkpoint > For Multiple Objects command.

To define a regular expression in a GUI checkpoint:

  1. Create a GUI checkpoint for an object in which you specify the checks. In this example, choose Insert > GUI Checkpoint > For Object/Window.
  2. The WinRunner window is minimized, the mouse pointer becomes a pointing hand, and a help window opens on the screen.

  3. Double-click a static text object.
  4. The Check GUI dialog box opens:
  5. To define a regular expression in a GUI checkpoint

  6. In the Properties pane, highlight the “Regular Expression” property check and then click the Specify Arguments button.
  7. The Check Arguments dialog box opens:
    Check Arguments dialog box
  8. Enter the regular expression in the Regular Expression box, and then click
  9. OK.
  10. If desired, specify any additional checks to perform, and then click OK to close the Check GUI dialog box.

An obj_check_gui statement is inserted into your test script.

Using a Regular Expression in a Text Checkpoint

You can use a regular expression in a text checkpoint, to locate a varying text string using win_find_text or object_find_text. For example, the statement:

obj_find_text ("Edit", "win.*", coord_array, 640, 480, 366, 284);

enables WinRunner to find any text in the object named “Edit” that begins with “win”.

Since windows often have varying labels, WinRunner defines a regular expression in the physical description of a window.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

WinRunner Topics