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

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

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

欢迎不吝赐教。

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航