Sie sind auf Seite 1von 16

WINRUNNER

Creating Dialog Boxes for Interactive Input

• WinRunner enable us to create dialog boxes that you can use


to pass input to your test during an interactive test run.
• We can create dialog boxes that pop up during an interactive
test run, prompting the user to perform an action—such as
typing in text or selecting an item from a list.
How to create Dialog boxes ?
• To create the dialog box, we should enter a TSL statement in
the appropriate location in our test script.

• During an interactive test run, the dialog box opens when the
statement is executed.

• By using control flow statements, you can determine how


WinRunner responds to the user input in each case.
Types of Dialog boxes
• Create_input_dialog
• Create_list_dialog
• Create_custom_dialog
• Create_browse_file_dialog
• Create_password_dialog
Creating an Input Dialog Box

Syntax:
create_input_dialog ( message );

Example..,
name = create_input_dialog ("Please type in your name.");
Creating a List Dialog Box

Syntax:
create_list_dialog ( title, message, list_items );
➤ title - is an expression that appears in the window banner of the dialog box.
➤ message - is one line of text that appear in the dialog box.
➤ list_items - contains the options that appear in the dialog box. Items are
separated by commas, and the entire list is considered a single string.

Example:
filename = create_list_dialog ("Select an Input File", "Please select one of the
following tests as input", "Batch_1, clock_2, Main_test, Flights_3, Batch_2");
Creating a Custom Dialog Box
• Syntax:
create_custom_dialog ( function_name, title, button_name,
edit_name1-n,check_name1-m );

• function_name - is the name of the function that is executed


when you click the “execute” button.
• title - is an expression that appears in the title bar of the
dialog box.
• button_name - is the label that will appear on the “execute”
button. You click this button to execute the contained function.
• edit_name - contains the labels of the edit
field(s) of the dialog box. Multiple edit field
labels are separated by commas, and all the
labels together are considered a single string.
• check_name - contains the labels of the check
boxes in the dialog box.Multiple check box
labels are separated by commas, and all the
labels together are considered a single string.
res = create_custom_dialog ("run_application1", "Initial Conditions", "Run",
"Application:, Geometry:, Background:, Foreground:, Font:", "Sound,
Speed");
Creating a Browse Dialog Box
• A browse dialog box allows us to select a file from a list of
files, and returns the name of the selected file as a string.
Syntax:
create_browse_file_dialog ( filter );

• filter sets a filter for the files to display in the Browse dialog
box. We can use wildcards to display all files (*.*) or only
selected files (*.exe or *.txt, etc.).
Example..,
filename = create_browse_file_dialog( "*.dll;*.exe" );
Creating a Password Dialog Box
• A password dialog box has two edit fields, an OK button, and a
Cancel button.

Syntax:

create_password_dialog ( login, password, login_out,


password_out );
• Login - is the label of the first edit field, used for user-name input. If you
specify an empty string (empty quotation marks), the default label
“Login”is displayed.
• Password - is the label of the second edit field, used for password input. If
you specify an empty string (empty quotation marks), the default label
“Password” is displayed. When the user enters input into this edit field, the
characters do not appear on the screen, but are represented by asterisks.
• Login_out - is the name of the parameter to which the contents of the first
edit field (login) are passed. Use this parameter to verify the contents of
the login edit field.
• Password_out - is the name of the parameter to which the contents of the
second edit field (password) are passed. Use this parameter to verify the
contents of the password edit field.
status = create_password_dialog ("", "", user_name, password);
Viritual Object Wizard
• We can teach WinRunner to recognize any bitmap in a
window as a GUI object by defining the bitmap as a virtual
object.

• Example:
set_window("Calculator");
win_mouse_click ("Calculator", 87, 175);
win_mouse_click ("Calculator", 204, 200);
win_mouse_click ("Calculator", 121, 163);
win_mouse_click ("Calculator", 242, 201);
• set_window ("Calculator");
• button_press("seven");
• button_press("plus");
• button_press("four");
• button_press("equal");
Transactions
• We can measure how long it takes to run a section of your test by
defining transactions.
• A transaction represents the business process that we are
interested in measuring.

• start_transaction
• end_transaction

• We must declare each transaction using a declare_transaction


statement somewhere in the test prior to the corresponding
start_transaction statement.
• The test report displays the time it took to perform the transaction.

Das könnte Ihnen auch gefallen