不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。                                           it is no use doing what you like, you have got to like what you do.

Robot用Excel做Datapool功能测试(转)

上一篇 / 下一篇  2006-12-22 15:45:55 / 个人分类:Robot技术

用Excel做Datapool实现Rational Robot 功能测试的一个实例51Testing软件测试网iFbr`9J~
Rational Robot是一个比较通用的软件测试工具。她主要通过录制(自动或手工)脚本用于功能测试和性能测试51Testing软件测试网JL0e6z@ `0_$R

IGP:d UK'gd0在手工修改Robot录制的GUI脚本时,经常用到Datapool这一概念,由于Rational自带的Datapool工具只能支持2000行的数据池纪录,而且编辑不是很方便。现用比较方便的Excel作为数据源,实现自动测试的功能。51Testing软件测试网G2} K })IQ V1dw2p
51Testing软件测试网B0e7K _ U-M z
前提条件:OS系统中已经安装Office。51Testing软件测试网2tl}cr]r/F5?b&H

$phBWj^HCj#[0[源码]
c$h%H6` G7Y0
-{%qP6h&pu/qs u/K0'$include "sqautil.sbh"
[@v;^ g@,o0Sub Main
4dBxX*Z{W5v;s'A0    Dim Result As Integer51Testing软件测试网3\ ~6ONmN
    dim excel as Object51Testing软件测试网@ |Wu,V9sF,H
    dim book as Object
M#p:d,jI6K0    dim worksheet as Object
Y6U5p"W?C(Y FD0    dim s_name as String
(|K.Q_ r*{hH0    dim s_pass as String
{'YK-W7\5i0    dim count as Integer
3V%e-AbzQE)O(?0
Z#],SD0? S0    'Initially Recorded: 2004-4-2  :16:5551Testing软件测试网]0{'P-C4iEP#S
    'scrīpt Name: AUT_1_Login51Testing软件测试网,mG ?_`H
   51Testing软件测试网LT:|9y?z"H2\
    Window SetContext, "Caption=Program Manager", ""
'G-K7A#S6A5t0Q/^ V s0    StartBrowser "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "WindowTag=WEBBrowser"
}*e,D+ByE2dMu)z$CJ0   51Testing软件测试网 |2Fvh_*A&V)|
   
,hnHt0v0    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''51Testing软件测试网!x(a&b%?Z)_kG
    'Initiliaze excel
-{2};WH\8|l'N0    on error resume next
#uR,}LD5sM8t0    Set excel = GetObject(,"excel.application")51Testing软件测试网-P*p9H_7Y'`j
    if(excel Is Nothing) then51Testing软件测试网4p/ee7oc$CL
        Set excel = CreateObject("excel.application")
Jw(I+Lf1s0        if(excel Is Nothing) then
dim3j*q+q0            MsgBox "Couldn't find Excel!"
U(P(p VN4TV0            Exit Sub51Testing软件测试网7JhD _tm
        End if
2P J*E&^%M#I0    End if
?E+m5] {2H2p0   
4\5G{;ih'V0    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+Pg'[0|,t!A @+a3|Tg)X8x0
2F.awIzq0    Set book = excel.Workbooks.Open("Your Book1.xls")51Testing软件测试网 ~-_t%o'o}F[
    Set worksheet = book.Worksheets("Your Excel sheet's name")
,gm%?2B*gI!b-kd0        51Testing软件测试网2t`+uA%~p1?+U(vF
    For count=1 To 251Testing软件测试网K Uej \RA:e
    s_name = worksheet.Cells(1,count).value
+Jb.` lZz|0    s_pass = worksheet.Cells(2,count).value
T"~\)g+g%|Lc6a8{0    'print s_name,s_pass
:mp@:?!n4i&`z0   
C0F9A)r%Fl#t0    Window SetContext, "Caption=Web应用系统 - Microsoft Internet Explorer", ""51Testing软件测试网o/?2C]O rv@/P o
    Browser SetFrame,"Type=HTMLFrame;HTMLId=mainframe",""
![bnUA}0    Browser NewPage,"HTMLTitle=Title",""51Testing软件测试网C3YFA[?-h6t
    EditBox Click, "Type=EditBox;Name=userAccount", "Coords=26,10"51Testing软件测试网-wab5J { n
    InputKeys s_name &"{TAB}"&s_pass51Testing软件测试网 P(Ba1i*S'og:a7Q
    PushButton Click, "Type=PushButton;HTMLText=登录"
7S \h.m d0   51Testing软件测试网.{C/p|(\0J;Ma3veu
    Window SetTestContext, "Caption=Web应用系统 - Microsoft Internet Explorer", ""51Testing软件测试网4]4~Or8V)p
    Browser SetFrame,"Type=HTMLFrame;HTMLId=mainframe",""
0[ E0A?9YFu)FJE0   
W9Sj X t.v:Tc]iL0    Window SetTestContext, "Caption=Microsoft Internet Explorer", ""51Testing软件测试网'|L3x:y)^Y)L
    Result = LabelVP (CompareProperties, "Text=输入错误,请重新输入!", "VP=Object Properties;ExpectedResult=FAIL")51Testing软件测试网0{R;_'z ISS@
    Window ResetTestContext, "", ""
"v"\@he d8{y(l3f0      
+gY&E8O/ZYKlL\0    Next count51Testing软件测试网WO*}6z4Fm

v:J"Q8|.vUpb]T Y${0    'Quit Excel'''''''''''''''''''''51Testing软件测试网q3n%t}{@QY*Y
    excel.Quit51Testing软件测试网%O\ U[v-Q
    Set excel = Nothing51Testing软件测试网%V`D7Q {4_"k
   51Testing软件测试网I/y h V%OSE
    Window CloseWin, "", ""51Testing软件测试网}$}Ky _i;j{
   
0KeD7Y$e0End Sub

TAG: Robot技术 软件测试技术

 

评分:0

我来说两句

Open Toolbar