一段Winrunner的样例脚本
上一篇 / 下一篇 2007-07-12 12:18:22 / 个人分类:性能测试
#########################################################################################################
*`z
ju4d'Jzh0#
6t;P4ZR'vt$D^tq0# Test Name : Date Boundary51Testing软件测试网yl]3|)}1l;sI
# Subject : Open Order Form
8D}^/Q;g\a0#
Z9q(YORPf0# Description : Checks that the input of illegal values in the Flight Date is blocked and that error messages51Testing软件测试网9Z3L*S%F:oTzn/\
# appear. The following input should be tested:51Testing软件测试网
Yy}2_4BYm0\
# 1. Flight Date Edit field is disabled when button is unchecked
5q `'UV+U@J2{X0# 2. Characters (not accepted)
iR{3Y!]0# 3. More than six numbers (not accepted)
!fAl ["zI z0# 4. Less than six numbers (OK is disabled)51Testing软件测试网%Ps,]U$Vz:SCTRTK
# 5. Invalid Month51Testing软件测试网0C.r*X.cC
# 6. Invalid date of the month
qdl8x(I2a]0# 7. No entry51Testing软件测试网{)l5LJ^;q
#
8i%Lj1{R0#
!XP+[sz BaVE0#########################################################################################################51Testing软件测试网T+g{$J(i/~T:R
#static variables:51Testing软件测试网&Sx B"g:]*o
static ret_val,date_str,i;
M+| R:C~.Q0# Constant declaration
n*?jz F^QY8D0static const DISABLED = FALSE;
gH C4`BT7N0# Variable declaration. Can be anything the user wants.
Z[^!pWMX0static date_string_of_chars = "as/cd/ef"; # Used in STEP 2. Characters (Not accepted).
o2p9G_ s*N,k!y0static date_seven_numbers = "12/34/567"; # Used in STEP 3. More than six numbers not accepted.51Testing软件测试网A6hD|o+c9Uk
static date_invalid_month = "13/20/95"; # Used in STEP 5. Invalid month.51Testing软件测试网%qkqzm1C
static date_invalid_day = "12/32/95"; # Used in STEP 6. Invalid date of month.51Testing软件测试网:u*o4o D
^a
static lib_path = getvar("testname") & "\\..\\flt_lib";51Testing软件测试网s2W)s/FVfhP.@
51Testing软件测试网7}h@0r6}2Y/L# Static function reinitialize (). Reinitializes Flight Date to OFF and clears the edit field.51Testing软件测试网
xPc4l0Yi7s
static function reinitialize ()
V
y
}*}?wcom0{
:VTP5H|(T ~0 auto ret_val;51Testing软件测试网}(P0C6P\(Z
set_window ("Open Order");
1bjcq|
~_Qw:jC0 obj_get_info ("FlightDateEdit", "enabled", ret_val);51Testing软件测试网3Gr&hG0X0?(VQnq
if (ret_val == TRUE) {
e q9Li
?A'}7J!]b0 set_window ("Open Order");51Testing软件测试网T;l,J\-u*^\A$zf
edit_set_insert_pos ("FlightDateEdit", 0, 0);51Testing软件测试网(I/vqTl0f
type ("
yCv%P\W6HAS0 }51Testing软件测试网1A)M ae;j"Vr
}
3H,Ur
X]-W0# Static function insert_date (). Inserts the date into the FlightDateEdit field.
/\vyl@0static function insert_date (in date)
K*V]Jn
j&I0{
hM%]
SL _ja0 set_window ("Open Order");
BJFcw0 edit_set_insert_pos("FlightDateEdit",0,0);
z6w["|/n0 type(date);51Testing软件测试网!P'rsi2~+T$DD"E0e
}51Testing软件测试网$R}"p/L8lJEm
dh7U?_1MM%eG0reload(lib_path);51Testing软件测试网F&B:WA;al&W8N
51Testing软件测试网xC4T PD8d;MY3P6d# Open the flight application51Testing软件测试网7lc0G ~'aOd5^b
rc = open_flight();51Testing软件测试网qUJ(P(lB(tJ
if (rc == E_GENERAL_ERROR){
R6YlGHW,Be0 tl_step(initialization, FAIL,couldnt_open_flight);
.z(u*u/C v7c+M0 clean_up();51Testing软件测试网s5b7Ebrz0Pa p
texit;51Testing软件测试网1T!E~l"Y_
}51Testing软件测试网wV4S)hF0v4iI"ja\z
9Wqc,BbA#w%O0
2qT8l,[4sJ_0i V)os0uV0# Initialization.51Testing软件测试网 XH.cRcBr,}1uCC
open_OpenOrderForm ();
D:e1Rrf
k([0
J:bus.o'V4O,A!s0# STEP 1. Flight Date Edit is disabled
set_window ("Open Order");51Testing软件测试网w0}3PWH
~C]/Y-j&^$X0# Checking to see if the edit field is disabled when button is unchecked51Testing软件测试网WUs[4p:Y P
obj_get_info ("FlightDateEdit", "enabled", ret_val);51Testing软件测试网7T5q.AWp+k$k
if (ret_val == DISABLED)
oD#J.K8C0 tl_step (disabled, PASS, flight_date_disabled);51Testing软件测试网r*C4G$M,R2@
else
7M
wfJ0T.E0t9mgs0 tl_step (disabled, FAIL, flight_date_not_disabled);
2Q:[&z;t-C0reinitialize ();
{3P/F%aXQUw-n0
t^6h-C9D"e/Z4s^g5A0# STEP 2. Characters (not accepted)
+S(R+{/e5tY0button_set ("Flight Date", ON);51Testing软件测试网O }+x8h @#H#ZtE
4`9Z,T)b(V0]0# Inserting a date of characters using variable, "date_string_of_chars", defined above.51Testing软件测试网S] bx"T
b_
insert_date (date_string_of_chars);
VB*c/efi*rBHU1]y
Z0edit_get_text ("FlightDateEdit", date_str);
5SkE1a.N4c7_0# Checking to see if application handled illegal open order procedure51Testing软件测试网[7F&ZMA*F8ms;R`
if (date_str == "__/__/__")
'ek`"T-m@0 tl_step (characters, PASS, chars_not_accepted);
HW9C Pc} tC0else51Testing软件测试网U
{+M6IA%v5U
tl_step (characters, FAIL, chars_accepted);51Testing软件测试网H'P+U:Z)tXx
reinitialize ();51Testing软件测试网 }Pe,L'_ dw1v-F
.Vi O%h|-dR_0# STEP 3. More than six numbers (not accepted)
U_ Q)rC6t:R*o0Hx8`&qDs7Pw
o0button_set ("Flight Date", ON);51Testing软件测试网/fz1Lu^S!S
# Inserting a date consisting of more than six numbers using variable, "date_seven_numbers", defined above.
I,X]iD,jZ#b1D0insert_date (date_seven_numbers);
0Q:v'~9zDT-d8L'u,R0edit_get_text ("FlightDateEdit", date_str);