利用txt来记录log. excel文件,用来存储参数化的值 :
以下是一个小例子来说明 日志记录与外部参数化文件的运用:
'首先创建一个日志文件,对测试的相关点进行记录。
Dim oFso,sLogPath,oFile,sUserName,sPassword,i,sUNameArr,oAuto
Const ForWriting = 8
sLogPath="D:\Logs\Flights Logs\Login.log"
set oAuto=createobject("lijing.operator") '此为集成好的类的运用,需注册
'调用函数:将excel中的值存到内存中(array).
sUNameArr=oAuto.ReadExcelForArray("C:\Documents and Settings\jason\桌面\Book1.xlsx",1)
For i = 2 To ubound(sUNameArr,1) Step 1
Set oFso=createobject("scripting.FileSystemObject")
set oFile=oFso.OpenTextFile(sLogPath,ForWriting)
'systemutil.Run "D:\Program Files\HP\Unified Functional Testing\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set sUNameArr(i,1)
oFile.WriteLine "***************************************"
oFile.WriteLine "测试时间为: " & now
sUserName=dialog("Login").WinEdit("Agent Name:").GetROProperty("text")
oFile.WriteLine "测试所登录的账号: " & sUserName
Dialog("Login").WinEdit("Password:").SetSecure "51345e2a0164a507b3b0fe2626cd1b8f549690e0" @@ hightlight id_;_2426326_;_script infofile_;_ZIP::ssf2.xml_;_
Dialog("Login").WinButton("OK").Click @@ hightlight id_;_2164228_;_script infofile_;_ZIP::ssf3.xml_;_
wait 2
If window("Flight Reservation").Exist Then
oFile.WriteLine "测试登录成功!"
else
oFile.WriteLine "测试登录失败!"
End If
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
oFile.Close
Set oFile = nothing
Set oFso=nothing
systemutil.Run "D:\Program Files\HP\Unified Functional Testing\samples\flight\app\flight4a.exe"
dialog("Login").Activate
Next
If dialog("Login").Exist Then
dialog("Login").Close
End If
msgbox "测试活动完成!"