刚刚用了
QTP的描述性编程,忽然想起用
WinRunner也用一下描述性编程。做了感觉还不错,呵呵。。。。
51Testing软件测试网K$R4d{q5G[ 以下是本人用WINDOW XP自带的一个计算器做的一个小例子:
*X/U8IiN`9c0#################################################################################
l
CL{*u"iu0#
51Testing软件测试网d4\ ^4?Ls*E#q4f\"q|p# Descrīption-------------Use Descrīption Programing to
Test the CALC in Window XP by WinRunner
*o1b K(ZQ$NrJA&w0#
(_tF/B
vg4e0# Tester------------------Lantian Wei
w#T)LC'c\0#
51Testing软件测试网A Rs%?T.rB{:P# Modify Time-----------2007-7-24
b/T6pHN(O4{ Z(U3I0#
51Testing软件测试网 {9x'?+so#################################################################################
`*Fxft V n2q0invoke_application("calc.exe","","c:\\windows\\system32\\",SW_SHOW);
*lbf&\
V
Z0static myarr[]={{1,"+",2,3},{1,"-",2,-1},{1,"*",2,2},{1,"/",2,0.5}};
*?(zD @H*D@b0win_activate("{class: window,label: Calculator}");
51Testing软件测试网!XiX8_%P/q#bZ6Z
uset_window("{class: window,label: Calculator}",5);
L)LKi9M#iF1QI0for(i=0;i<4;i++)
!R b"hd9SsYc!A0{ for(j=0;j<3;j++)
51Testing软件测试网f^(LOd
Cy,PU button_press("{class: push_button,label:"&myarr[i,j]&"}");
51Testing软件测试网8[aF0IX*fJ Q lu button_press("{class: push_button,MSW_class: Button,label:=}");
51Testing软件测试网 _"C7N(Y H c4u]8S edit_get_text ("{class: edit}", result);
51Testing软件测试网5t2tJ,P2{'mrcif(index(myarr[i,j],".")==0)
0Xz4B5D~6zP0{
d8NG!r"N:S]\O0 if(result==myarr[i,j]&". ")
b)n\-V/Y'rI0 tl_step("CheckAnswer",0,"The calculatation is right:"&myarr[i,j-3]&" "&myarr[i,j-2]&" "&myarr[i,j-1]&" = "result);
/}9J!H{-Jd`0 else
S!yB,G
J-x|7Y0 tl_step("CheckAnswer",1,"The calculatation is wrong:"&myarr[i,j-3]&" "&myarr[i,j-2]&" "&myarr[i,j-1]&" != "result);
51Testing软件测试网/X(X#^y kl:y2p|M wait(1);
!mR;J'hL/sI^0 }
51Testing软件测试网Q/k]Qfelse
51Testing软件测试网:G-Oo6R)ns5u!~L{
51Testing软件测试网x2C8}'J m8~9w if(result==myarr[i,j]&" ")
51Testing软件测试网D;y.c}!q!r tl_step("CheckAnswer",0,"The calculatation is right:"&myarr[i,j-3]&" "&myarr[i,j-2]&" "&myarr[i,j-1]&" = "result);
51Testing软件测试网 C4i{4s ]$I else
)]N@:L o0 tl_step("CheckAnswer",1,"The calculatation is wrong:"&myarr[i,j-3]&" "&myarr[i,j-2]&" "&myarr[i,j-1]&" != "result);
51Testing软件测试网F7e Qj(Q/{ u7bX wait(1);
,ze3i]bg#A"^%g0 }
51Testing软件测试网ne)PI~$}*zG#j ?}
(|L+oX%C0win_close("{class: window,label: Calculator}");
&u)cb8ETG,KT Z:v0V&w.To)@0以上是本人用描述性编程写的脚本,至此现丑了。如有不足之处还请大家指正!在此先表示感谢!
51Testing软件测试网0tN)Y:_{\ iGqF通过这个例子的练习,我发现它确实有好多优点,比如你从此不用在关心那烦人的对象库了,而一个
测试脚本里基本上在对象库中出现的问题最多了。然而它还是有缺点的,比如对于无法识别的对象,它就无能为力了,而对于那些OBJECT对象,它的支持也不好。所以如果WR对应用程序识别的满好的话,不如用描述性编程试试。
6SE#H|*_c-q(f0