|
关于static型的值,应该怎么进行比较呢?
这是网上找到的一段实例代码:
Option Explicit
Dim fso
'数据驱动文件路径,数据文件,当前行
Dim ddFilePath, ddFile, ddCurrLine
'执行日志文件路径,日志文件
Dim logFilePath, logFile
Dim strInfo
ddFilePath = Environment.Value("TestDir") & "\ddFile.txt"
logFilePath = Environment.Value("TestDir") & "\logFile.txt"
'====写入测试用例数据到数据驱动文件中===='
Set fso = CreateObject("Scripting.FileSystemObject")
'OpenTextFile第三个参数如果是False表示如果文件一定要存在.
Set ddFile = fso.OpenTextFile(ddFilePath, 2, True)
ddFile.WriteLine "ad,Mercury,Agent name must be at least 4 characters long."
'ddFile.WriteLine "admin,merc,Incorrect password. Please try again"
'ddFile.WriteLine "admin,Mercury,Flight Reservations"
ddFile.Close
'====写入测试结果到数据日志文件中===='
Set logFile = fso.OpenTextFile(logFilePath, 2, True)
logFile.WriteLine "************************************************************"
logFile.WriteLine "************************************************************"
logFile.WriteLine "*************************测试日志***************************"
logFile.WriteLine "******************用例名称:用户登陆**************************"
logFile.WriteLine "**********************作者:Holly zhao*************************"
logFile.WriteLine "********************执行时间:" & Date & "*********************"
logFile.WriteLine "************************测试开始:**************************"
'从ddFile中读取测试数据
Set ddFile = fso.OpenTextFile(ddFilePath, 1, True)
While NOT ddFile.AtEndOfLine
ddCurrLine = Split(ddFile.ReadLine, ",")
'SystemUtil.CloseProcessByName "Flight4a.exe"
SystemUtil.Run Environment.Value("ProductDir") & "\samples\flight\app\flight4b.exe"
Dialog("Login").WinEdit("Agent Name:").Set ddCurrLine(0)
Dialog("Login").WinEdit("Password:").Set ddCurrLine (1)
Dialog("Login").WinButton("OK").Click
If Dialog("Login").Dialog("Flight Reservations").Exist Then
if Dialog("Login").Dialog("Flight Reservations").Static("errInfo").GetROProperty("text") = ddCurrLine(2) Then
‘为什么我找不到Static("errInfo")对象?我查看了所有相关的Static,但是没有找到。这个Static("errInfo")是自定义的吗?
logFile.WriteLine "测试成功!"
MsgBox Dialog("Login").Dialog("Flight Reservations").Static("errInfo").GetROProperty("text")
Else
MsgBox Dialog("Login").Dialog("Flight Reservations").Static("errInfo").GetROProperty("text")
logFile.WriteLine "测试失败!"
End If
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
Else
If Window("Flight Reservation").Exist Then
logFile.WriteLine "测试成功!"
End If
Window("Flight Reservation").Close
End If
Wend
logFile.WriteLine "==========================测试结束==================================="
logFile.WriteLine "*********************************************************************" |
|