我的地盘我做主! 博客:http://tester2test.cnblogs.com/   msn:win_soft@163.com

一段Winrunner的样例脚本

上一篇 / 下一篇  2007-07-12 12:18:22 / 个人分类:性能测试

51Testing软件测试网;?0`{2[+dF6h

#########################################################################################################
*` z j u4d'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:o Tzn/\
#    appear.  The following input should be tested:51Testing软件测试网 Yy}2_4B Ym0\
#     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:SCT RTK
#     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+[szBaVE0#########################################################################################################51Testing软件测试网T+g {$J(i/~T:R

51Testing软件测试网6QM)s/{Ku3J`

#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;

a:hi,`%i b!azJx0

gHC4`BT7N0# Variable declaration.  Can be anything the user wants.
Z[^!pW M X0static 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

51Testing软件测试网i8E'C:KZ

static lib_path = getvar("testname") & "\\..\\flt_lib";51Testing软件测试网s2W)s/F VfhP.@

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 ("");
y Cv%P\W6HAS0 }51Testing软件测试网1A)M ae;j"Vr
}

!|D H9?1|0

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/L8l JEm

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软件测试网q UJ(P(l B(tJ
if (rc == E_GENERAL_ERROR){
R6YlGHW,Be0  tl_step(initialization, FAIL,couldnt_open_flight);
.z(u*u/C v7c+M0 clean_up();51Testing软件测试网s5b7Ebrz0Pap
 texit;51Testing软件测试网1T!E~l"Y_
}51Testing软件测试网wV4S)hF0v4iI"ja\z

9Wqc,BbA#w%O0 

2qT8l,[4sJ_0

iV)os0uV0# Initialization.51Testing软件测试网 XH.cRcBr,}1uCC
open_OpenOrderForm ();

4[&A']2{Q4n7O T M^0

D:e1Rrf k([0
J:bus.o'V4O,A!s0# STEP 1.  Flight Date Edit is disabled

K4l!z$\ T9H0 51Testing软件测试网;KdN b"vx4}

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 ();

J C'Jb[0WV,x?0

{3P/F%aXQUw-n0
t^6h-C9D"e/Z4s ^g5A0# STEP 2.  Characters (not accepted)

~{*K#qa'B1yRv0

+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);

Tqd U+_RTw&~0

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*o0

Hx8`&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);

Ep&vbF0

z"k-lF8gwR%I(_*b0# Checking to see if application handled illegal open order procedure
zGbRZh E m9j0if (date_str == "12/34/56")
.be/m(\%kJ2h0 tl_step(more_than_six, PASS, more_than_six_not_accepted);51Testing软件测试网%i?#fH[!`qN/k0I%o-|
else
g dVQ)N0 tl_step(more_than_six, FAIL, more_than_six_accepted);
V E0Q S6M*C wU0reinitialize ();51Testing软件测试网9o|!`D$O.^v

|5Izcz v?ik0# STEP 4. Less than six numbers (OK is disabled)51Testing软件测试网n lU\ C6g

51Testing软件测试网:bq inyI(P

edit_set_insert_pos ("FlightDateEdit", 0, 0);

.r|pX0GRm?E9dS0

(Ch9XreC?0# Using for_loop to systematically check if OK button is disabled for any date with less than six numbers in it
f L~6z9G,w-yE2`3O+y0for (i = 1; i <= 6; i++) {
hOxU`+N"d0 type(i);51Testing软件测试网6}*JQ!Ch4?Pe
 if (button_check_enabled ("OK", TRUE) == E_OK)51Testing软件测试网(J W1ni"r(pR)d
  break;

]%R ISu$D2c1{0

P xk+LU~g} {0}51Testing软件测试网*jO-jaCT4a-E

gN)|FN#S&DTB0#  The actual check to make sure that OK was disabled for date less than six numbers51Testing软件测试网+{/w+r FfjK
ts_msg = sprintf(ok_not_disabled, i);
m$Pq;H-Amp z0if (i < 6)
$V}*H)Ut+x!`R;c^0 tl_step (less_than_six, FAIL, ts_msg);
rpH1SPT[0else
QBt2E t/K?g D:z1s}0 tl_step (less_than_six, PASS, ok_disabled);51Testing软件测试网J/?9r d6s LNkD
reinitialize ();51Testing软件测试网@np0?.qv:? f

51Testing软件测试网:r)PJv8J

# STEP 5. Invalid Month

/CVY w;g)i a+s"Q0 51Testing软件测试网.R^7h;|f1}

set_window ("Open Order");51Testing软件测试网y3x.^u"@4Q
# Inserting a date with an invalid month using variable, "date_invalid_month", defined above.
9@XS6z O8Yf,?9A:Q&J0insert_date (date_invalid_month);

]S7k8K @0

|"|_c2Bm0# Checking to verify that unless there is a valid month, an error message will pop up when trying to press "OK"
]+OO%D,ud0set_window("Open Order");51Testing软件测试网A#Yo gCa4R
button_press("OK");51Testing软件测试网 v%m"c AE&i)ln
if(win_exists("Flight Reservation Message",10) != E_OK){
A8N1_ ~Wl0 tl_step (invalid_month, FAIL, invalid_month_msg_popup);
%_(K`*g*X}0k0 clear_main_window();
c-r|Y;mg7D0 open_OpenOrderForm ();51Testing软件测试网4eX#Q*k hA.ym#hN
}
*|W%~+Z+x:\3lJRH0else{
a*W~!gfk;WK0 set_window("Flight Reservation Message");
$K3w~ |pXa1| c0 static_get_text("Message", txt);51Testing软件测试网r4z`o5B jV
 if(txt !=invalid_month_entered_msg)51Testing软件测试网8e2} _$?_2a
  tl_step (invalid_month, FAIL, invalid_month_wrong_msg);51Testing软件测试网3~U0Y'o~Bp2Jzf
 else
$S4qIbO?9v0  tl_step (invalid_month, PASS, invalid_month_correct_msg);
a(^bo)q[ Z0 button_press("OK");
z``M[y0}
rA/p+} y;S| Y0reinitialize ();51Testing软件测试网Ob-MRg

!vG2r4t&lxH0
&n+F*N'oO y[ aa0# STEP 6.  Invalid day of month.51Testing软件测试网uKS-}-F L"maUX

{)pz7lu-^0set_window ("Open Order");51Testing软件测试网b3P$? NP3]7L
# Inserting a date with an invalid day using variable, "date_invalid_day", defined above.
q6N*zBK!hdx}0insert_date (date_invalid_day);

QV7N2AT-\c|0

Ml/@'{j9T D#O0# Checking to verify that unless there is a valid day of the month the "OK" button will be disabled51Testing软件测试网jdr+e&P|
set_window("Open Order");
[ E+lR5?:P0button_press("OK");
Z"T5Sh | d&H*}0if(win_exists("Flight Reservation Message",10) != E_OK){
^:s'[.{]*p0 tl_step (invalid_day, FAIL, invalid_day_no_err_msg);
3s ov"||z0S0 clear_main_window();
7w hC.ZW1lk)~e0 open_OpenOrderForm ();
V*K J0P5`p0}51Testing软件测试网$E"bs)Z5K
else{
xFhK(fH(L E.q S)f0 set_window("Flight Reservation Message");51Testing软件测试网0O0Y9x'L:e@(e
 static_get_text("Message", txt);51Testing软件测试网{ sw8`~'`Q.`
 if(txt !=invalid_day_entered_msg)51Testing软件测试网i&Ze)yM"pE"j
  tl_step (invalid_day, FAIL, invalid_day_wrong_err_msg);51Testing软件测试网V?9vnK@ [2Z
 else51Testing软件测试网y:he7LHrRj
  tl_step (invalid_day, PASS, invalid_day_not_accepted);51Testing软件测试网1z6xP0j ]D!nI9B
 button_press("OK");51Testing软件测试网rB'vx,a-x{ tsh
}51Testing软件测试网6T$QZ GvN~:kg r
reinitialize ();51Testing软件测试网 \3W+U9crLU

51Testing软件测试网&Aa:K^/Ax

51Testing软件测试网_.^*Q{/}
# STEP 7.  No Entry.

)A nSp,yO2Z3g0

/`6f1j W)A8lZz:n0[0J0set_window ("Open Order");51Testing软件测试网 T AQW c b2J
# Inserting no date to see if OK is disabled.51Testing软件测试网k@y5{3k"~~&V
insert_date ("__/__/__");

-J0?_8Tm~0

jxL3Gd0a:^r0# Checking to see if OK is disabled without any date set in edit field51Testing软件测试网(bKF _s)n
if (button_check_enabled ("OK", TRUE) != E_OK)51Testing软件测试网i7EpmR_
 tl_step (no_entry, PASS, ok_button_disabled);
#otpm:E$W(B T0else51Testing软件测试网.\@$V"SYu2K @
 tl_step (no_entry, FAIL, ok_button_enabled);

}iz6G.WD1n{0

$[G'S%K,?v!U0
A&a]Nym/f#_n0# Returning to initial state.
8\CFB4X0button_press ("Cancel");51Testing软件测试网 Ev)vUd0p5RnY*Q }
clean_up();

J6lVEJ0

9V^`'i~)s!Mc051Testing软件测试网wu J1ic5WV/HG
# End of test.51Testing软件测试网9ek:p\:B@$Tq
51Testing软件测试网_0Z7I yQaF

51Testing软件测试网9i5s/u Re9w%cL3ZI
51Testing软件测试网7H:y5n.Z/[U ?;r3Q
测试者家园 2006-12-08 09:24 发表评论
51Testing软件测试网%{#qd([/h
51Testing软件测试网Dn @6{{:R6F Q
Link URL: http://www.cnblogs.com/tester2test/archive/2006/12/08/586031.html

TAG:

 

评分:0

我来说两句

Open Toolbar