3、二进制文件
下面是以二进制方式写入文件的语句格式及其说明:
格式:
Put [#]fileNumber ,[Pos], Var
功能: 用二进制方式,从文件的中指定的位置开始写入,所给变量长度的数据
说明:
(1)FileNumber是以二进制方式打开的文件号.
(2)Pos用来指定写操作发生时的字节位置,若省略,则使用当前文件指针位置.
(3)Var是用来存放写入的数据的变量.该语句会自动根据var变量包含的字节长度写入文件,如果Var是一个可变长度的字符串变量,则传送的字节数等于Var中目前的字节数.
使用方法可参考二进制文件的读操作.
用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
文章来源于领测软件测试网 https://www.ltesting.net/