|
Sub Main
Dim Result As Variant
dim msgtext,j,k
dim checkstate as string
Dim iMaxRows As Integer '定义EXCEL文档中的最大行
Dim iMaxColumns As Integer '定义EXCEL文档中的最大列
Dim iRow As Integer '定义行循环变量
Dim sAddons As String '定义附加险存储变量
Dim sRowData As String
Dim sCellData As String
Dim iColumn As Integer
Dim col As String
Dim objExcel As Object '定义Excel对象变量
Dim objWorkBook As Object '定义WorkBook对象变量
Dim objWorkSheet As Object '定义Sheet对象变量
Dim objRange As Object '定义Range对象变量]
Dim objCell As Object
'b: msgtext = "请输入登陆人的代号:"
' j= inputbox$(msgtext)
' msgtext = "请输入登陆人的相应密码:"
' k= passwordbox$(msgtext)
Const sFileName = "D:\My Documents\050514\excel\登陆名称.xls" '定义Excel文件所在地
Const sSheet = "Sheet1" '定义工作表的名称
On Error GoTo Debugger '当代码进行出现异常时,跳转到Debugger,显示错误描述,并停止运行
Set objExcel = CreateObject("Excel.Application") '建立Excel应用程序实例
Set objWorkBook = objExcel.Workbooks.Open(sFileName) '打开Excel文件
Set objWorkSheet = objWorkBook.WorkSheets(sSheet) '定位目标工作表
Set objRange = objWorkBook.WorkSheets(sSheet).UsedRange '取工作表中已使用的单元区域
iMaxRows = objRange.Rows.Count
For iRow = 2 To iMaxRows '从第二行开始,从Excel文件中提取数据。
For iColumn = 65 To 67 '从列A开始到列B开始,用ASCII码做循环,取车险测试用例
col = Chr$(iColumn) '将列的ASCII码转换成字母,例如66->"B"
sCellData = objWorkSheet.Range(col & iRow).Value '取单元格数据,存入sCellData变量
sRowData = sRowData+sCellData+"," '将从单元格的中取出的数据拼成字符串,以,号分隔
Next iColumn
dim mz,mm,dm as string
mz = GetField(sRowData,1,",") '代号
mm = GetField(sRowData,2,",") '密码
dm = GetField(sRowData,3,",") '名称
sRowData=""
StartApplication "K:\haihui\050625client.exe"
Result = WindowVP (Exists, "Name=Form1;Type=Form", "VP=登陆窗口;Wait=1,2")'判断系统窗口是否出现,
if Result = 1 then
if mz = "" then
goto a
end if
Window SetContext, "Name=Form1;Type=Form", ""
GenericObject DblClick, "Name=TeThemeEdit1;Type=CustomControl", "Coords=43,3"
inputkeys dm '填写登陆人代码
SQALogMessage sqaPass, "输入登陆人代码:" & dm, ""
Window SetContext, "Name=Form1;Type=Form", ""
GenericObject DblClick, "Name=TeThemeEdit2;Type=CustomControl", "Coords=43,3"
inputkeys mz '填写登陆人代码
SQALogMessage sqaPass, "输入登陆人代码:" & mz, ""
Window SetContext, "Name=Form1;Type=Form", ""
GenericObject DblClick, "Name=TeThemeEdit3;Type=CustomControl", "Coords=33,10"
InputKeys mm '填写登陆人密码
SQALogMessage sqaPass, "输入登陆人密码:" & mm, ""
elseif Result = 0 then
SQALogMessage sqaPass, "登陆窗口未出现", ""
else
goto Debugger
end if
a: Window SetContext, "Name=Form1;Type=Form", ""
GenericObject Click, "Name=TeThemeButton1;Type=CustomControl", "Coords=39,11"
Result = WindowVP (Exists, "Caption=提示", "VP=提示;Wait=1,2;ExpectedResult=FAIL")
if Result = 0 then
Result = SQAGetProperty ("Caption=提示;\;type=Label;ObjectIndex=1","Text", CheckState)
SQALogMessage sqaPass, "提示内容" & CheckState, ""
Window SetContext, "Caption=提示", "" '提示窗口属性
PushButton Click, "Text=确定"
'退出程序
Window SetContext, "Name=Form1;Type=Form", ""
GenericObject Click, "Name=TeThemeButton2;Type=CustomControl", "Coords=27,9"
'不备份退出
Window SetContext, "Caption=提示", ""
PushButton Click, "Text=否(N)"
' goto b '重新开始'下一个
end if
Next iRow
objWorkBook.Close
objExcel.Quit
Set objRange = Nothing '释放objRange
Set objWorkSheet = Nothing '
Set objWorkBook = Nothing '释放objworkBook
Set objExcel = Nothing '释放objExcel
Debugger: '错误处理
IF Err<>0 Then '如果错误值不等于0 那么
MsgText = "错误号:" & Err & "发生行:" & Erl & "错误信息:" & Error$ '给 msgtext 赋值
MsgBox MsgText '出现错误窗口,出错内容为 msgtext 的内容
objWorkBook.Close
objExcel.Quit
Set objRange = Nothing '释放objRange
Set objWorkSheet = Nothing '释放objWorkSheet
Set objWorkBook = Nothing '释放objworkBook
Set objExcel = Nothing '释放objExcel
Exit Sub '结束脚本
Else '否则
Exit Sub
End If
End Sub
这个脚本中是否包含验证点?
我本来认为 Result = WindowVP (Exists, "Name=Form1;Type=Form", "VP=登陆窗口;Wait=1,2")
就是验证点了,但是在Rational TestManager的报告中并不能跑出验证。
可以给我讲解一下,什么才是验证点吗?或者给几个例子。谢谢大家了 |
|