Monday, July 2, 2007

WinRunner SynchronizationPoint

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.
Testing Date Operations

The recommended workflow while checking dates in the application is as follows:

Define the date format(s) currently used in the application.
Create baseline tests by recording tests on the application. While recording, insert checkpoints that will check the dates in the application.
Run the tests (in Debug mode) to check that they run smoothly. If a test incorrectly identifies non-date fields as date fields or reads a date field using the wrong date format, user can override the automatic date recognition on selected fields.
Run the test (in Update mode) to create expected results.
Run the tests (in Verify mode). If the user wants to check how the application performs with future dates, user can age the dates before running the test.


Analyze test results to pinpoint where date-related problems exist in the application. If the user change date formats in the application, user should repeat the workflow described above after redefining the date formats used in the application.

To specify date formats:
Go to Date > Set Date Formats. The Set Date Formats dialog box opens. User can select each date format used in the application. User should move the most frequently-used date format in the application to the top of the list. WinRunner considers the top date format first.

Checking Dates in GUI Objects
User can use GUI checkpoints to check dates in GUI objects (such as edit boxes or static text fields).
The default check for edit boxes and static text fields is the date.
The default check for tables performs a case-sensitive check on the entire contents of a table, and checks all the dates in the table.

Overriding Date Settings
When debugging the tests, user may want to override user can override in the following ways:

Aging of a specific date format: - User can override the aging of a specific date format so that it will be aged differently than the default aging setting.

To override the aging of a date format:
Go to Date > Set Date Formats. The Set Date Formats dialog box opens.
Click the Advanced button. The Advanced Settings dialog box opens.
In the Format list, select a date format.
Click Change. The Override Aging dialog box opens.

User can increment the date format by a specific number of years, months and days. If the user wants no aging then use 0. User can choose a specific date for the selected date format by selecting the "Change all date to" option or user can stick to the default aging.

Overriding Aging or date format of a specific object: - User can define that a specific object that resembles a date should not be treated as a date object.

To override settings for an object:
Go to Date > Override Object Settings. The Override Object Settings dialog box opens.
Click the pointing hand button and then click the date object.
To override date format settings or to specify that the object is not a date object, clear the Use default format conversion check box

Note: When WinRunner runs tests, it first examines the general settings defined in the Date Operations Run Mode dialog box. Then, it examines the aging overrides for specific date formats. Finally, it considers overrides defined for particular objects.

Checking Dates with TSL

User can enhance the recorded test scripts by adding the following TSL date functions:

date_calc_days_in_field (field_name1, field_name2);
field_name1 The name of the 1st date field.
field_name2 The name of the 2nd date field.

The date_calc_days_in_field function calculates the number of days between the dates appearing in two date fields. Note that the specified date fields must be located in the same window.

date_calc_days_in_string (string1, string2);
string1 The name of the 1st string.
string2 The name of the 2nd string.

The date_calc_days_in_string function calculates the number of days between two numeric dates’ strings. Note that the specified strings must be located in the same window.

date_field_to_Julian (date_field);
date_field The name of the date field.

The date_field_to_Julian function translates a date string to a Julian number. For example, if the date 121398 (December 13, 1998) appears in the specified date field, WinRunner translates the date to the Julian number 2451162.

date_string_to_Julian (string)
string The numeric date string.

The date_string_to_Julian function translates a date string to a Julian number. For example, it calculates the string 12/13/98 (December 13, 1998) to 2451162.

date_is_field (field_name, min_year, max_year);
field_name The name of the field containing the date.
min_year Determines the minimum year allowed.
max_year Determines the maximum year allowed.

The date_is_field function checks that a field contains a valid date by determining whether the date falls within a specified date range.

date_is_string (string, min_year, max_year);
string The numeric string containing the date.
min_year Determines the minimum year allowed.
max_year Determines the maximum year allowed.

The date_is_string function checks that a numeric string contains a valid date by determining whether the date falls within a specified date range.

date_is_leap_year (year);
year A year, for example "1998".

The date_is_leap_year function determines whether a year is a leap year. The function returns "0" if the year is not a leap year or "1" if the year is a leap year.

date_month_language (language);
language The language used for month names.

The date_month_language function enables user to select the language used for month names in the application so that WinRunner can identify dates. User can select English, French, German, Spanish, Portuguese, or Italian. If the application uses a different language, select "Other" and define the names for all 12 months.

1 comment:

Naveen Davis said...

its informative blog for me .. actually i looking for a documentation for sync techniques in WinRunner ,...

My Contents