QTP: Resumen código común

En primer lugar, abrir la URL de IE / abierta Vuelo programa especificado

SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE","120.27.144.13"
SystemUtil.Run "E:\QTP\QuickTest Professional\samples\flight\app\flight4a.exe"

Dos, método común 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

Tres o cuatro maneras importantes

''''''''''''''''''''''''''''''''''''''''''''''''''''
'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

En cuarto lugar, la impresión del pop

c = Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")
MsgBox (c) 

En quinto lugar, verificar que un valor está presente

If c<>"" Then	'如果不是空值,证明订票成功;否则订票失败;
	Reporter.ReportEvent 0,"success","success"
else
	Reporter.ReportEvent 1,"fail","fail"
End If  '关闭程序

En sexto lugar, para verificar si hay una ventana

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

 

 

 

 

 

 

 

 

 

 

 

 

Publicados 349 artículos originales · ganado elogios 161 · vistas 190 000 +

Supongo que te gusta

Origin blog.csdn.net/qq_42192693/article/details/103435241
Recomendado
Clasificación