一段Winrunner的样例脚本
上一篇 / 下一篇 2007-04-09 07:27:14 / 个人分类:其他
q6y{ ~vwlG'k0#########################################################################################################
:g$P"d3JE t5Bn0#
3u#zcP)y4v0# Test Name : Date Boundary
3S,qd"X7v!AFL0# Subject : Open Order Form51Testing软件测试网V#LI.{s$|
#51Testing软件测试网ME'`I^!WpC$]0@
# Description : Checks that the input of illegal values in the Flight Date is blocked and that error messages51Testing软件测试网!o&jef?.?3Nt
# appear. The following input should be tested:51Testing软件测试网9X#IZmo6Ew&v
# 1. Flight Date Edit field is disabled when button is unchecked51Testing软件测试网xo
F,Q0a[bN
# 2. Characters (not accepted)
G9m{#D*?!FY3FN0# 3. More than six numbers (not accepted)
7b)U6K%{Y VH&S/D0# 4. Less than six numbers (OK is disabled)51Testing软件测试网sI @)V2s5I:Z!l
# 5. Invalid Month
T4o dMl1KA!Y0u0# 6. Invalid date of the month51Testing软件测试网'Y!{#@U(_d#@7Q5R
# 7. No entry
y*k,C~4L0#51Testing软件测试网?+b|U;IFC.O
#51Testing软件测试网
e4Tt6J-cn[)Z
#########################################################################################################51Testing软件测试网8mfcgF+V
#static variables:
V*t1B8n!Y0static ret_val,date_str,i;51Testing软件测试网+WWr \+p,q2D@`:b#J
# Constant declaration51Testing软件测试网:ImNZPr;j*P,L h
static const DISABLED = FALSE;51Testing软件测试网C/}+jb y3p8u_
.}\ pnQ3bWu_r/nG I0# Variable declaration. Can be anything the user wants.
(k(ihIT#B,ZqJ0static date_string_of_chars = "as/cd/ef"; # Used in STEP 2. Characters (Not accepted).51Testing软件测试网.dqA5V^}
static date_seven_numbers = "12/34/567"; # Used in STEP 3. More than six numbers not accepted.51Testing软件测试网2f;l#?`xE
static date_invalid_month = "13/20/95"; # Used in STEP 5. Invalid month.51Testing软件测试网K0x*H7Z'l
static date_invalid_day = "12/32/95"; # Used in STEP 6. Invalid date of month.
static lib_path = getvar("testname") & "\\..\\flt_lib";51Testing软件测试网,lI@SF j;Be
j\ xFs-fi3L0# Static function reinitialize (). Reinitializes Flight Date to OFF and clears the edit field.
nh2I#o$}9|D+js0static function reinitialize ()51Testing软件测试网3RR;z|X$Q5pcu
{51Testing软件测试网4L,F(gJ b/~&aj]
auto ret_val;51Testing软件测试网7x4tyn]M
]Y
set_window ("Open Order");51Testing软件测试网7cRmlS
obj_get_info ("FlightDateEdit", "enabled", ret_val);
2pc8w{0E1b[ L0 if (ret_val == TRUE) {51Testing软件测试网[*Zu!RI$dt_$Y&Dr5U
set_window ("Open Order");
!W7M'htH+^`0 edit_set_insert_pos ("FlightDateEdit", 0, 0);
M!~ pcO0 type ("
}51Testing软件测试网5_'uHt6Z"c
}51Testing软件测试网/{(F6v(za
# Static function insert_date (). Inserts the date into the FlightDateEdit field.
'X4JM'mf0static function insert_date (in date)51Testing软件测试网+|`vQjWQmn*Rnj
{51Testing软件测试网Oc*|[_h
set_window ("Open Order");51Testing软件测试网/Em%g-e(}rNQ6J
edit_set_insert_pos("FlightDateEdit",0,0);51Testing软件测试网,A2_
_.Da7O
type(date);
r5a4J6xe(~0}51Testing软件测试网-_"L&^#IvB.rfnPG
2q,^1F.w3G0reload(lib_path);
]0At0kY D0C"I0'a"l:`^g0# Open the flight application
Z v)wq4x0rc = open_flight();
[dm%Xq*uy0if (rc == E_GENERAL_ERROR){51Testing软件测试网n*{m0t.|
S
tl_step(initialization, FAIL,couldnt_open_flight);
x2r0e!n
PyH$m0 clean_up();51Testing软件测试网J{/WYi
texit;
R*y5~E![2\v0}
Q1a"@:d*s$c-bx0 51Testing软件测试网 pH:v}9bC"M
# Initialization.
Y!cx6ic5i[(Ez
l0open_OpenOrderForm ();51Testing软件测试网"M}|@Q c*f
N^5EKq+~0# STEP 1. Flight Date Edit is disabled51Testing软件测试网El.n(jA1xu.]
set_window ("Open Order");51Testing软件测试网:k-d4J`!XC
51Testing软件测试网0us/]Fl Vdm|s# Checking to see if the edit field is disabled when button is unchecked
aDB(t2nw`Q3B S0obj_get_info ("FlightDateEdit", "enabled", ret_val);51Testing软件测试网L9Dd/[Xe|fy,X
if (ret_val == DISABLED)51Testing软件测试网/pptr"n2d&ml'x9by
tl_step (disabled, PASS, flight_date_disabled);
9u8c&u
m&T"pk~0else51Testing软件测试网5oa9J B1AP
tl_step (disabled, FAIL, flight_date_not_disabled);
:P0y~*c]-V B0reinitialize ();51Testing软件测试网_2P#?1{3v
Dlt e/Ms%\#J sa051Testing软件测试网qs]g
{8p
# STEP 2. Characters (not accepted)51Testing软件测试网1WfaHlk|
button_set ("Flight Date", ON);51Testing软件测试网A+^'l9c7F%sa |
C0|!W:PM0# Inserting a date of characters using variable, "date_string_of_chars", defined above.51Testing软件测试网G| PRp/qS
insert_date (date_string_of_chars);51Testing软件测试网0X9or[*hf(n
edit_get_text ("FlightDateEdit", date_str);51Testing软件测试网G5|b[zRl!|
G
# Checking to see if application handled illegal open order procedure51Testing软件测试网Q_
To%s~-e
if (date_str == "__/__/__")51Testing软件测试网JN%Ia^L~,R
tl_step (characters, PASS, chars_not_accepted);
6K(z@,PK0else51Testing软件测试网3DP j&Z|8D
tl_step (characters, FAIL, chars_accepted);51Testing软件测试网 @/s*o5`V1gQn0G
reinitialize ();
# STEP 3. More than six numbers (not accepted)
f;[nP8K^C0 51Testing软件测试网1~o7X+@.K*T)\ Rbutton_set ("Flight Date", ON);51Testing软件测试网,?G/sB&Ih4Be8FS\ b
# Inserting a date consisting of more than six numbers using variable, "date_seven_numbers", defined above.
p P e4t ii}K0insert_date (date_seven_numbers);51Testing软件测试网
|s_a2?K
edit_get_text ("FlightDateEdit", date_str);
# Checking to see if application handled illegal open order procedure51Testing软件测试网'XoHC+h+j
if (date_str == "12/34/56")51Testing软件测试网%a{9L9GVy5e"v
tl_step(more_than_six, PASS, more_than_six_not_accepted);51Testing软件测试网k/v\O$_^
else51Testing软件测试网 W%Si$y(A%E
S+W
tl_step(more_than_six, FAIL, more_than_six_accepted);51Testing软件测试网t;?lVK6XG
reinitialize ();
%D;J6U.u*DS0# STEP 4. Less than six numbers (OK is disabled)
^8Q6Jln;YT0 51Testing软件测试网 a1lRQ X|edit_set_insert_pos ("FlightDateEdit", 0, 0);