Quality Testing

Quality is delighting customers

Share some sample Winrunner Scripts here.

Views: 1226

Reply to This

Replies to This Discussion

***********************
Open Order Script
***********************
# Flight Reservation
win_activate ("Flight Reservation");
set_window ("Flight Reservation", 1);
menu_select_item ("File;Open Order...");

# Open Order
set_window ("Open Order", 1);
button_set ("Order No.", ON);
edit_set ("Edit", "1");
button_press ("OK");

**********************************
Database related operations
**********************************
db_connect("ss","DSN=flight32");
db_execute_query("ss","select * from orders",rc1);
report_msg("the no records before insert :" & rc1);

# Flight Reservation
win_activate ("Flight Reservation");
set_window ("Flight Reservation", 2);
menu_select_item ("File;New Order");
obj_type ("MSMaskWndClass","0512054");
list_select_item ("Fly From:", "Los Angeles"); # Item Number 3;
list_select_item ("Fly To:", "Frankfurt"); # Item Number 1;
obj_mouse_click ("FLIGHT", 39, 22, LEFT);

# Flights Table
set_window ("Flights Table", 1);
list_select_item ("Flight", "20206 LAX 10:12 AM FRA 05:23 PM AA $112.20"); # Item Number 1;
button_press ("OK");

# Flight Reservation
set_window ("Flight Reservation", 3);
edit_set ("Name:", "sfdsfds");
button_press ("Insert Order");
wait(10);


db_connect("ss","DSN=flight32");
db_execute_query("ss","select * from orders",rc2);
report_msg("the no records after insert :" & rc2);

if(rc2>rc1)
tl_step("Insert",0,"Insert done");
else
tl_step("Insert",1,"Insert Fail");

**********************
Data Driven Test
**********************
table = "default.xls";
rc = ddt_open(table, DDT_MODE_READ);
if (rc!= E_OK && rc != E_FILE_OPEN)
pause("Cannot open table.");
ddt_get_row_count(table,table_RowCount);
for(table_Row = 1; table_Row <= table_RowCount; table_Row ++)
{
ddt_set_row(table,table_Row);

# Shell_TrayWnd
set_window ("Shell_TrayWnd", 2);
button_press ("Start");

# BaseBar
set_window ("BaseBar", 5);
toolbar_select_item ("ToolbarWindow32_1", "Programs;WinRunner;Sample Applications;Flight 1A");

# Login
set_window ("Login", 4);
edit_set ("Agent Name:", ddt_val(table,"Agent_Name"));
password_edit_set("Password:", password_encrypt(ddt_val(table,"Password")));
button_press ("OK");

# Flight Reservation
set_window ("Flight Reservation", 16);
menu_select_item ("File;Exit");

}
ddt_close(table);
------------------------------------------------------------------
Script to check the record is inserted or not
------------------------------------------------------------------
db_connect("ss","DSN=flight32");
db_execute_query("ss","select * from orders",rc1);
report_msg("the no records before insert :" & rc1);

# Flight Reservation
win_activate ("Flight Reservation");
set_window ("Flight Reservation", 2);
menu_select_item ("File;New Order");
obj_type ("MSMaskWndClass","0512054");
list_select_item ("Fly From:", "Los Angeles"); # Item Number 3;
list_select_item ("Fly To:", "Frankfurt"); # Item Number 1;
obj_mouse_click ("FLIGHT", 39, 22, LEFT);

# Flights Table
set_window ("Flights Table", 1);
list_select_item ("Flight", "20206 LAX 10:12 AM FRA 05:23 PM AA $112.20"); # Item Number 1;
button_press ("OK");

# Flight Reservation
set_window ("Flight Reservation", 3);
edit_set ("Name:", "sfdsfds");
button_press ("Insert Order");
wait(10);


db_connect("ss","DSN=flight32");
db_execute_query("ss","select * from orders",rc2);
report_msg("the no records after insert :" & rc2);

if(rc2>rc1)
tl_step("Insert",0,"Insert done");
else
tl_step("Insert",1,"Insert Fail");


-------------------------------------------------
Runtime Database Check Point
-------------------------------------------------
# Flight Reservation
set_window ("Flight Reservation", 2);
menu_select_item ("File;Open Order...");

# Open Order
set_window ("Open Order", 1);
button_set ("Order No.", ON);
edit_set ("Edit", "83");
button_press ("OK");

# Flight Reservation
set_window ("Flight Reservation", 14);
edit_set ("Name:", "sdanda");
edit_set("Tickets:",3);
button_press ("Update Order");
wait(9);

if(db_record_check("list2.cvr", DVR_ONE_OR_MORE_MATCH, record_num)==E_OK)
tl_step("Matching",0,"More Matching records");
else
tl_step("Matching",1,"No Matching Records");
Good Start Kamali.

---------------------------------------------------------------------------------------------------------------------------------------------------
Script to connect to the database and displaying the all records information From MS Access
---------------------------------------------------------------------------------------------------------------------------------------------------
if((db_connect("flight1","DSN=flight32")==E_OK);
{
report_msg(“Connection Successful”);
}
#C:\\Program Files\\Mercury Interactive\\WinRunner\\samples\\flight\\app\\
db_execute_query("flight1","select orders.customer_name,orders.order_number from orders",rcount);
for(i=1;i<=rcount;i++)
{
db_get_row("flight1",i,row_content);
split(row_content, line_arr, "\t");
val1 = db_get_field_value ("flight1","#"&i,"customer_name");
val2 = db_get_field_value ("flight1","#"&i,"order_number");
report_msg(val1);
report_msg(val2);
}
db_disconnect("flight1");


------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Script to connect to the database and displaying the all records information when there is DSN Problem(Oracle)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
db_connect("TestSession","DSN=REPAIRCATALOG;UID=CATALOG;PWD=catalog;DBQ=Oracle87;DBA=W;APA=T;FEN=T;FRC=10;FDL=10;LOB=T;RST=T;FRL=F;PFC=10;TLO=0;");
db_execute_query("TestSession","Select LOGIN.USER_ID,LOGIN.PWD From RC_LOGIN LOGIN",Recordcount);
for(i=0;i
Userid = db_get_field_value("TestSession","#"&i,"USER_ID");
Password = db_get_field_value("TestSession","#"&i,"PWD");
report_msg("Login id is " & Userid " and Password is " & Password);
}
db_disconnect("TestSession");

#Getting the first record value
Userid = db_get_field_value("TestSession","#0","USER_ID");


------------------------------------------
Compile module problem:
------------------------------------------
Main test:File >Test properties>Test type—Main test
load("comp1",0,0);
# Flight Reservation
set_window ("Flight Reservation", 5);
menu_select_item ("File;Open Order...");

# Open Order
set_window ("Open Order", 2);
button_set ("Order No.", ON);
edit_set ("Edit", "1");
button_press ("OK");
# Flight Reservation
set_window ("Flight Reservation", 14);
wait(5);
edit_get_text("Name:",text);
x=compare(text);
report_msg(x);
wait(5);
edit_set ("Tickets:", "1");
button_press ("Update Order ");



File name:comp1

Comilemodule :File >Test properties>Test type—Compile module
function compare(ast,out k){
if(ast=="John Doe")
k="equal";

else
k="not equal";
return k;
}

Batch Test:
Call a test: Call “c:\\temp\\sc1”();

# Shell_TrayWnd
set_window ("Shell_TrayWnd", 2);
button_press ("Start");

# BaseBar
set_window ("BaseBar", 5);
toolbar_select_item ("ToolbarWindow32_1", "Run...");

# Run
win_activate ("Run");
set_window("Run",8);
list_select_item ("Open:_0", "cmd");
Count the no of item:
list_get_info ("Open:_0", "count",val);
for(i=0;i
{
Get the no of item
list_get_item("Open:_0",i,var1);
print(var1);
}
report_msg("The total num item is" val);
# Item Number 12;
button_press ("Cancel");

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service