WR中的数据驱动和脚本调用
上一篇 / 下一篇 2006-12-28 23:49:21 / 个人分类:Winrunner 技术
使用数据驱动来测试Windows自带的计算器,并调用一个Compiled Module进行比较实际结果和预期结果是否相符,将其写入指定文件中。51Testing软件测试网S?8Exrv| Q
oB/Z6_K?(M:k(o0下述脚本在WR 7.6上调试通过。51Testing软件测试网;h9_` jH!\"W
L L_k
d;Bz0#################################################################################
T5P'HckS\0#scrīpt Name: calcDataDriver51Testing软件测试网lF B;Nr7v&`
#Test Type: Main Test
%N
Y)e5I5i!qI?
R&aW3sb0#51Testing软件测试网]&fiAE8o+bhm:I
#Function Descrīption: Using Data Driver to test calc.exe, and call a compiled #module to compare the Actual Result with the Expected Result. 51Testing软件测试网8HI2\-X8d
#################################################################################51Testing软件测试网,X0Hc;a!M"hQr3T
51Testing软件测试网:]5fRfJ,V'[!D
@2Fm0A(GNPm7Q0if (load("compareResult")==1)
I2L6B$Ja{&}VQ$TO0{51Testing软件测试网6w-It*[tW4_g Z)n
report_msg("Compiled Module failed to load!");
:g/s3dv([B;d&_0 texit;
GAhki0}51Testing软件测试网]Nh7w*hnC e
if(GUI_load("C:\\calc.gui")!= E_OK)
k1E.mt;mh1U0{
2?[;Ny
m,D)r0 report_msg("GUI failed to load!");51Testing软件测试网4^-_
M-IBf8U8A:z M
texit;
.GE~wj!Y s,uJ0}
U6p5wfjM"H@2z0myResultLog = "C:\\myResultLog.txt";
'dB^]#v"R0table = "C:\\data_text.xls";
bs9r$~cZ%St0rc = ddt_open(table, DDT_MODE_READ);51Testing软件测试网M-N}4tT9s
if (rc!= E_OK && rc != E_FILE_OPEN){
@VsI(a+?t
]
W)G0 pause("Cannot open table.");51Testing软件测试网sb-v$BhN Qlk"{
texit;
kBC*qgMo(\0}
+s$FNO%[P{ Lr0if(invoke_application("C:\WINDOWS\system32\calc.exe","","C:\WINDOWS\system32\calc.exe",SW_SHOWNORMAL)!=E_OK){51Testing软件测试网6l4eu!{2D+P!uZ#?
report_msg("程序未正常打开");51Testing软件测试网q-F&jV/m8a}+d/kt
texit;51Testing软件测试网1ua*eStO
}51Testing软件测试网p\EXV%V`(W!K"P
else{
;[j Md6wk
`Bk0 ddt_get_row_count(table,table_RowCount);51Testing软件测试网p^a0O8_e
for(table_Row = 1; table_Row <= table_RowCount; table_Row ++)
3U\O:X5|
q-H[S7w0 {51Testing软件测试网R,y8KI
u
ddt_set_row(table,table_Row);51Testing软件测试网 s wi&hH:R"W
str1 = ddt_val(table,"Data1");51Testing软件测试网
f/M[
Ue?
B
n1 = length(str1);
.m|K:V+Os*K4b7O0 # 计算器51Testing软件测试网6K9Dw0h6x[$ce
set_window ("计算器", 1);