Interview Questions

How to Create a Test Using Winrunner (6)

Introduction To WinRunner Basics


(Continued from previous question...)

How to Create a Test Using Winrunner (6)


Synchronization points

Synchronization points enable user to solve anticipated timing problems between the test and the application. By inserting a synchronization point in the test script, user can instruct WinRunner to suspend the test run and wait for a cue before continuing the test. It is useful for testing client-server systems, where the response time of the server varies significantly.

For Analog testing, user can also use a synchronization point to ensure that WinRunner repositions a window at a specific location. While running a test, the mouse cursor travels along exact coordinates. Repositioning the window enables the mouse pointer to make contact with the correct elements in the window.

There are three kinds of synchronization points:

Synchronization point for Property Values of Objects or Windows
Synchronization point for Bitmaps of Objects and Windows
Synchronization point for Bitmaps of Screen Areas

Depending on which Synchronization Point command user has choose, WinRunner either captures the property value of a GUI object or a bitmap of a GUI object or area of the screen, and stores it in the expected results folder (exp ). User can also modify the property value of a GUI object that is captured before it is saved in the expected results folder. When the user runs the test, WinRunner suspends the test run and waits for the expected bitmap or property value to appear. It then compares the current actual bitmap or property value with the expected bitmap or property value saved earlier. When the bitmap or property value appears, the test continues.

Synchronization point for Property Values of Objects or Windows
When the user wants WinRunner to wait for an object or a window to have a specified property, user creates a property value synchronization point. A property value synchronization point is a synchronization point that captures a property value of Objects or Windows. It appears as a _wait_info statement in the test script, such as button_wait_info or list_wait_info.

For example, user can tell WinRunner to wait for a button to become enabled or for an item to be selected from a list.

To create synchronization point for Property Values of Objects or Windows
Go to Insert >Synchronization Point > For Object/Window Property.

When the user passes the mouse pointer over the application, objects and windows flash.

To select a window, user has to click the title bar or the menu bar of the desired window. To select an object, user has to click the object. A dialog box opens containing the name of the selected window or object. User can specify which property of the window or object to check, the expected value of that property, and the amount of time that WinRunner waits at the synchronization point.

Syntax:-button_wait_info (button, property, value, time);
button The logical name or description of the button.
property Any of the properties listed.
value The property value.
time Indicates the maximum interval, in seconds, before the next statement is executed.


The button_wait_info function waits for the value of a button property and then continues test execution. If the property does not return the required value, the function waits until the time expires before continuing the test run. The other function used for synchronization point for Property Values of Objects or Windows are

edit_wait_info Waits for the value of an edit property.
list_wait_info Waits for the value of a list property.
menu_wait_info Waits for the value of a menu property.
obj_wait_info Waits for the value of an object property.
scroll_wait_info Waits for the value of a scroll property.
spin_wait_info Waits for the value of a spin property.
static_wait_info Waits for a the value of a static text property.
statusbar_wait_info Waits for the value of a status bar property.
tab_wait_info Waits for the value of a tab property.
win_wait_info Waits for the value of a window property.


Synchronization point for Bitmaps of Objects and Windows
br> When the user wants WinRunner to wait for a visual cue to be displayed, user has to create a bitmap synchronization point. In a bitmap synchronization point, WinRunner waits for the bitmap of an object or a window, to appear. It appears as a win_wait_bitmap or obj_wait_bitmap statement in the test script.br> br> To create synchronization point for Bitmaps of Objects and Windows
Go to Insert >Synchronization Point>For Object/Window Bitmap.

To select the bitmap of an entire window, user has to click the window’s title bar or menu bar. To select the bitmap of an object, user has to click the object. During a test run, WinRunner suspends test execution until the specified bitmap is redrawn, and then compares the current bitmap with the expected one captured earlier. If the bitmaps match, then WinRunner continues the test.

Syntax:-obj_wait_bitmap (object, bitmap, time);
object The logical name or description of the object. The object may belong to any class.

bitmap A string expression that identifies the captured bitmap.

time Indicates the interval between the previous input event and the capture of the current bitmap, in seconds. This parameter is added to the timeout
The obj_wait_bitmap function synchronizes a test run. It ensures that the bitmap of a specified GUI object appears on the screen before the test continues.

Waiting for Bitmaps of Screen Areas

User can create a bitmap synchronization point that waits for a bitmap of a selected area in the application. User can define any rectangular area of the screen and capture it as a bitmap for a synchronization point. It appears as a win_wait_bitmap or obj_wait_bitmap statement in the test script.

Syntax: - obj_wait_bitmap (object, bitmap, time [, x, y, width, height]);
x, y For an area bitmap: the coordinates of the upper left corner, relative to the object in which the selected region is located. width, height For an area bitmap: the size of the selected region, in pixels.

To create synchronization point Bitmaps of Screen Areas
Go to Insert >Synchronization Point >For Screen Area Bitmap.

The mouse pointer becomes a crosshairs pointer; user can use the crosshairs pointer to outline a rectangle around the area. The area can be any size, it can be part of a single window, or it can intersect several windows. WinRunner defines the rectangle using the coordinates of its upper left and lower right corners. These coordinates are relative to the upper left corner of the object or window in which the area is located. If the area intersects several objects in a window, the coordinates are relative to the window. If the selected area intersects several windows, or is part of a window with no title (a popup menu, for example), the coordinates are relative to the entire screen (the root window).

During a test run, WinRunner suspends test execution until the specified bitmap is displayed. It then compares the current bitmap with the expected bitmap. If the bitmaps match, then WinRunner continues the test.

In the event of a mismatch, WinRunner displays an error message, when the mismatch_break testing option is on. User can make the mismatch_break testing option off. Execute the following setvar statement:

setvar ("mismatch_break", "off");
WinRunner disables the mismatch_break testing option. The setting remains in effect during the testing session until it is changed again, either with another setvar statement or from the corresponding Break when verification fails check box in the Run >Settings category of the General Options dialog box. Using the setvar function changes a testing option globally, and this change is reflected in the General Options dialog box. However, user can also use the setvar function to set testing options for a specific test, or even for part of a specific test.

The main difference between the wait () and Synchronization Point is the wait () pauses test execution for the specified interval. But the Synchronization point only wait until the specified bitmap or object is displayed.

Syntax: - wait (seconds [, milliseconds]);
seconds The length of the pause, in seconds. The valid range of this parameter is from 0 to 32,767 seconds.
milliseconds The number of milliseconds that are added to the seconds.

(Continued on next question...)

Other Interview Questions