用Excel做Datapool10

上一篇 / 下一篇  2007-09-14 10:04:49

用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
    'scrīpt 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

TAG:

 

评分:0

我来说两句

日历

« 2024-05-10  
   1234
567891011
12131415161718
19202122232425
262728293031 

我的存档

数据统计

  • 访问量: 10211
  • 日志数: 28
  • 图片数: 1
  • 建立时间: 2007-09-11
  • 更新时间: 2007-09-14

RSS订阅

Open Toolbar