用Excel做Datapool实现Rational Robot 功能测试的一个实例

Rational Robot是一个比较通用的软件测试工具。她主要通过录制(自动或手工)脚本用于功能测试和性能测试。

在手工修改Robot录制的GUI脚本时,经常用到Datapool这一概念,由于Rational自带的Datapool工具只能支持2000行的数据池纪录,而且编辑不是很方便。现用比较方便的Excel作为数据源,实现自动测试的功能。

前提条件:OS系统中已经安装Office。

[源码]

'$include "sqautil.sbh"
Sub Main
    Dim Result As Integer
    dim excel as Object
    dim book as Object
    dim worksheet as Object
    dim s_name as String
    dim s_pass as String
    dim count as Integer

    'Initially Recorded: 2004-4-2  :16:55
    'Script Name: AUT_1_Login
   
    Window SetContext, "Caption=Program Manager", ""
    StartBrowser "C:/Program Files/Internet Explorer/IEXPLORE.EXE", "WindowTag=WEBBrowser"
   
   
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Initiliaze excel
    on error resume next
    Set excel = GetObject(,"excel.application")
    if(excel Is Nothing) then
        Set excel = CreateObject("excel.application")
        if(excel Is Nothing) then
            MsgBox "Couldn't find Excel!"
            Exit Sub
        End if
    End if
   
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    Set book = excel.Workbooks.Open("Your Book1.xls")
    Set worksheet = book.Worksheets("Your Excel sheet's name")
       
    For count=1 To 2
    s_name = worksheet.Cells(1,count).Value
    s_pass = worksheet.Cells(2,count).Value
    'print s_name,s_pass
   
    Window SetContext, "Caption=Web应用系统 - Microsoft Internet Explorer", ""
    Browser SetFrame,"Type=HTMLFrame;HTMLId=mainframe",""
    Browser NewPage,"HTMLTitle=Title",""
    EditBox Click, "Type=EditBox;Name=userAccount", "Coords=26,10"
    InputKeys s_name &"{TAB}"&s_pass
    PushButton Click, "Type=PushButton;HTMLText=登录"
   
    Window SetTestContext, "Caption=Web应用系统 - Microsoft Internet Explorer", ""
    Browser SetFrame,"Type=HTMLFrame;HTMLId=mainframe",""
   
    Window SetTestContext, "Caption=Microsoft Internet Explorer", ""
    Result = LabelVP (CompareProperties, "Text=输入错误,请重新输入!", "VP=Object Properties;ExpectedResult=FAIL")
    Window ResetTestContext, "", ""
     
    Next count

    'Quit Excel'''''''''''''''''''''
    excel.Quit
    Set excel = Nothing
   
    Window CloseWin, "", ""
   
End Sub

注:列出一段简短的代码,只是起到抛砖引玉的作用,Rational Suit的功能非常强大,我希望能结识更多的朋友,一同学习,一起提高整个业界的软件产品质量。

      我的联系方式:Email:liqk@slof.com

                                 QQ:26205478

      欢迎不吝赐教。

      如要转贴,请保持本文档的完整性。谢谢!

 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值