一段Winrunner的样例脚本
上一篇 / 下一篇 2007-03-13 17:02:00 / 个人分类:性能测试
TyO+C|4?0#########################################################################################################51Testing软件测试网D3?hw`0h0G
#51Testing软件测试网S'g
S iv|
a
# Test Name : Date Boundary51Testing软件测试网;V}6C { M6] ~K7I
# Subject : Open Order Form
"bIil] {0#51Testing软件测试网?VJY#S
# Description : Checks that the input of illegal values in the Flight Date is blocked and that error messages
a%?R}?AL8f0# appear. The following input should be tested:51Testing软件测试网E8B6l&D0n+s@N_[-^
# 1. Flight Date Edit field is disabled when button is unchecked51Testing软件测试网3MdMaK?
# 2. Characters (not accepted)
sp
lqHf`MuL0# 3. More than six numbers (not accepted)51Testing软件测试网5ksJ.RGl
# 4. Less than six numbers (OK is disabled)51Testing软件测试网L j/px1I^
# 5. Invalid Month51Testing软件测试网Ke+rBNbQ)Au(J
# 6. Invalid date of the month51Testing软件测试网u2UF'@;uNZ"\
# 7. No entry
3E2? i'H:@ rkc0i:@\ E!{0#
*am9d'c;{;C0#51Testing软件测试网A"j$lH-Hlq
#########################################################################################################51Testing软件测试网b o:l&~S7W6Q#pd:W p
#static variables:51Testing软件测试网_~Em`
static ret_val,date_str,i;51Testing软件测试网t
P5Ae$k/S0i7U*r)Y"C
# Constant declaration51Testing软件测试网 o,Qy`8D;rEZ
static const DISABLED = FALSE;51Testing软件测试网6FV[N~9t
# Variable declaration. Can be anything the user wants.
3[rK$l?&Z&s?8J!H0static date_string_of_chars = "as/cd/ef"; # Used in STEP 2. Characters (Not accepted).
0q3K|:?K0static date_seven_numbers = "12/34/567"; # Used in STEP 3. More than six numbers not accepted.51Testing软件测试网aheN8y5M5H
static date_invalid_month = "13/20/95"; # Used in STEP 5. Invalid month.
a/lMWf3r0|E0static date_invalid_day = "12/32/95"; # Used in STEP 6. Invalid date of month.
static lib_path = getvar("testname") & "\\..\\flt_lib";51Testing软件测试网g%aXU4Bo1@
51Testing软件测试网/v;~1Ms"v2x# Static function reinitialize (). Reinitializes Flight Date to OFF and clears the edit field.
Dh+U#}6a,w3y|}0static function reinitialize ()51Testing软件测试网/?vx }4bP
{
]8a Y6y X+o%M;P0 auto ret_val;51Testing软件测试网*`)d G7J!J5P
set_window ("Open Order");51Testing软件测试网 |Z3TJ.|%HX,f+@
f
obj_get_info ("FlightDateEdit", "enabled", ret_val);
(Q9h"GL'j0@Ke0 if (ret_val == TRUE) {
v$vgn$^B T0 set_window ("Open Order");51Testing软件测试网rY/av!f{!f]
edit_set_insert_pos ("FlightDateEdit", 0, 0);
'?_(RcYC U0 type ("
/cB[ dHW`A0 }51Testing软件测试网;z*{p2jbV-xX
}51Testing软件测试网?$LIt|!y[u4b F
# Static function insert_date (). Inserts the date into the FlightDateEdit field.51Testing软件测试网&Uw3X?l*_cC
static function insert_date (in date)
{;ieA5Mm0{
G,X`_cKK\
F ~0 set_window ("Open Order");51Testing软件测试网/o~9n4L%gVUxqf
edit_set_insert_pos("FlightDateEdit",0,0);
v{;M _;a{nY^0 type(date);51Testing软件测试网O;J/mtkA4fv
}51Testing软件测试网7?aSSS/A_
reload(lib_path);
;c-l.B J5n8Q]h"T0 Z}4A7FoC0# Open the flight application51Testing软件测试网,y%Rf-Rq8E
rc = open_flight();
V[{pbM#o^"~0if (rc == E_GENERAL_ERROR){
xN^e@?3e4H9X$cu0 tl_step(initialization, FAIL,couldnt_open_flight);
B2mw7QT+e?sW0 clean_up();
[&}kz Ai)r#U5N|4n0 texit;
+QTrt!w0}51Testing软件测试网,e Q4n(X#Ey}
51Testing软件测试网)uA3{B7Z!a1[
!O]hf.U3GMw D-E0# Initialization.51Testing软件测试网NvrB2cp
open_OpenOrderForm ();51Testing软件测试网-KRK?o[z
%X;Fi%r$x#Ca051Testing软件测试网!`9DvqM g Jb8C#Fc
# STEP 1. Flight Date Edit is disabled51Testing软件测试网dS6d3vT%A:K-p
set_window ("Open Order");
ZT^?!kg+O)g,a0@Qdu$]y9s,ZV0# Checking to see if the edit field is disabled when button is unchecked
-G&o/sr@-AgU0obj_get_info ("FlightDateEdit", "enabled", ret_val);51Testing软件测试网dDND]&h#|e
if (ret_val == DISABLED)51Testing软件测试网B
D-[[Bzb7xs
tl_step (disabled, PASS, flight_date_disabled);
&sl aBF*YlT0else
l2I(m L^w2G-dq0 tl_step (disabled, FAIL, flight_date_not_disabled);
1~l
UW0V0reinitialize ();51Testing软件测试网e4Qxr"A
/nRv1NB)CW(y051Testing软件测试网8UI.Z8]H'Q2~
Xf
# STEP 2. Characters (not accepted)51Testing软件测试网k$G qL,B],qQy
button_set ("Flight Date", ON);
5sr_Xi*R#o)R0 51Testing软件测试网\R2}vs7\9|s%vQqZ# Inserting a date of characters using variable, "date_string_of_chars", defined above.
"f6xZ'`%cS0insert_date (date_string_of_chars);
7Rm)t%P:he
cqz0edit_get_text ("FlightDateEdit", date_str);51Testing软件测试网+Q-B0J9oxj
# Checking to see if application handled illegal open order procedure51Testing软件测试网*i2j!R~&U
if (date_str == "__/__/__")51Testing软件测试网F(x9Q%|w#^v
tl_step (characters, PASS, chars_not_accepted);51Testing软件测试网Sr
Fhf
else
&dRX
v+~"iTr1mH0 tl_step (characters, FAIL, chars_accepted);
1^wi!_"n
|W5X)r0reinitialize ();