Archive for the ‘Software Test’ Category

QTP

1.QTP Sample 登录测试脚本:

Dim istatus
Dim text1
For i=1 to DataTable.GetSheet(“Action1”).GetRowCount ‘循环Action1 Sheet 里面的数据
SystemUtil.Run “C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe”
Dialog(“Login”).WinEdit(“Agent Name:”).Set DataTable.GetSheet(“Action1”).GetParameter(“name”).ValueByRow(i)’DataTable(“name”, “Action1”)’dtGlobalSheet
Dialog(“Login”).WinEdit(“Password:”).SetSecure DataTable.GetSheet(“Action1”).GetParameter(“pwd”).ValueByRow(i) 
istatus=DataTable.GetSheet(“Action1”).GetParameter(“status”).ValueByRow(i)
Dialog(“Login”).WinButton(“OK”).Click
If Dialog(“Flight Reservations”).Exist Then ‘判断第三方界面是否存在,即错误警告界面

if Dialog(“Flight Reservations”).Static(“Agent name must be at least 4 characters long.”).Exist Then
text1=Dialog(“Flight Reservations”).Static(“Agent name must be at least 4 characters long.”).GetROProperty(“Text”)

elseif Dialog(“Flight Reservations”).Static(“Incorrect password. Please”).GetROProperty(“Text”).Exist then
text1=Dialog(“Flight Reservations”).Static(“Incorrect password. Please”).GetROProperty(“Text”) ‘存在获取界面的Text值赋予text1

elseif Dialog(“Flight Reservations”).Static(“Password must be at least 4 characters long”).Exist then
text1=Dialog(“Flight Reservations”).Static(“Password must be at least 4 characters long”).GetROProperty(“Text”)
elseif Dialog(“Flight Reservations”).Static(“Please enter agent name”).Exist then
text1=Dialog(“Flight Reservations”).Static(“Please enter agent name”).GetROProperty(“Text”)
else Dialog(“Flight Reservations”).Static(“please enter password”).Exist
text1=Dialog(“Flight Reservations”).Static(“please enter password”).GetROProperty(“Text”)
End If

If text1=istatus then ‘如果Text是预期结果的值,打印text1
Reporter.ReportEvent micPass,DataTable.GetSheet(“Action1”).GetParameter(“case”).ValueByRow(i),DataTable.GetSheet(“Action1”).GetParameter(“status”).ValueByRow(i)
else
Reporter.ReportEvent micFail,”异常”,text1 ‘ 否则异常
end if
wait(2) ‘可有可无
Dialog(“Flight Reservations”).WinButton(“确定”).Click ‘关掉错误警告界面
Dialog(“Login”).WinButton(“Cancel”).Click ‘关掉本次登录界面,便于下一个循环
else
Reporter.ReportEvent micPass,DataTable.GetSheet(“Action1”).GetParameter(“status”).ValueByRow(i),DataTable.GetSheet(“Action1”).GetParameter(“case”).ValueByRow(i)
Window(“Flight Reservation”).Close
End If

Next

‘ For i=1 to DataTable.GetSheet(“Action1”).GetRowCount
‘ DataTable.setCurrentRow(i)
‘ DataTale.Raw(“columnname,”Action1”);

脚本下载地址 http://dl.dbank.com/c01dbcjxya

Advertisements