一,通过IE打开指定网址/打开Flight程序
SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE","120.27.144.13"
SystemUtil.Run "E:\QTP\QuickTest Professional\samples\flight\app\flight4a.exe"
二,datable常用方法
'------------------获取得到DataTable总行数的命令'------------------
AllRowCount = DataTable.GetSheet("Action1").GetRowCount
msgbox AllRowCount
'------------------动态获取DataTable中当前行和设置当前行'------------------
'获取当前行
CurrentRow = DataTable.GetSheet("Action1").GetCurrentRow
msgbox CurrentRow
'设置当前行
DataTable.GetSheet("Action1").SetCurrentRow(5)
CurrentRow = DataTable.GetSheet("Action1").GetCurrentRow
msgbox CurrentRow
'------------------动态获取DataTable中指定行的值'------------------
getValueByRow1 = DataTable.GetSheet("Global").GetParameter("A").ValueByRow(2)
msgbox getValueByRow1
getValueByRow2 = DataTable.GetSheet("Action1").GetParameter("A").ValueByRow(2)
msgbox getValueByRow2
'------------------动态获取DataTable中指定列的值'------------------
GetValue1 = DataTable("A","Global")
msgbox GetValue1
GetValue2 = DataTable("A","Action1")
msgbox GetValue2
GetValue3 = DataTable(1, "Global")
msgbox GetValue3
GetValue4 = DataTable(1, "Action1")
msgbox GetValue4
'------------------动态地在DataTable中添加新列并赋值'------------------
DataTable.GlobalSheet.AddParameter "Column1","Value1"
GetNewValue1 = DataTable("Column1", "Global")
msgbox GetNewValue1
DataTable.LocalSheet.AddParameter "Column2","Value2"
GetNewValue2 = DataTable("Column2", "Action1")
msgbox GetNewValue2
三,四种重要方法
''''''''''''''''''''''''''''''''''''''''''''''''''''
'GetTOProperty使用案例
ValueOfTo=Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").GetTOProperty("name")
msgbox ValueOfTo
''''''''''''''''''''''''''''''''''''''''''''''''''''
'GetTOProperties使用案例
Set TestObject = Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下")
Set Properties =TestObject.GetTOProperties()
PropertiesCount=Properties.Count
Print "对象总计存在" & PropertiesCount & "个封装属性。"
For i=0 to PropertiesCount-1
ProName = Properties(i).Name
ProValue = Properties(i).Value
Print ProName & "=" & ProValue
Next
Set Properties = Nothing
Set TestObject = Nothing
''''''''''''''''''''''''''''''''''''''''''''''''''''
'SetTOProperty使用案例
Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").SetTOProperty("name","百度一下下下")
''''''''''''''''''''''''''''''''''''''''''''''''''''
'GetROProperty使用案例
ValueOfRo = Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").GetROProperty("value")
msgbox ValueOfRo
四,弹窗打印
c = Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")
MsgBox (c)
五,验证某个值是否存在
If c<>"" Then '如果不是空值,证明订票成功;否则订票失败;
Reporter.ReportEvent 0,"success","success"
else
Reporter.ReportEvent 1,"fail","fail"
End If '关闭程序
六,验证某窗口是否出现
If Browser("论坛 - Powered by Discuz!").Page("论坛 - Powered by Discuz!").Link("退出").Exist Then
Reporter.ReportEvent 0,"login success","login success login success"
else
Reporter.ReportEvent 1,"login fail","login fail login fail"
End If