qtp结合httpwatch监听请求响应时间,服务器ip,返回状态码,从而对出错的接口进行简单分析
Dim URL
Dim linkStatue
URL="
www.baidu.com"
Set control=CreateObject("HttpWatch.Controller")
Set plugin=control.IE.New()
plugin.Log.EnableFilter(false)
plugin.Clear()
plugin.Record()
plugin.GotoURL(URL)
wait(2)
Browser("百度一下,你就知道").Page("百度一下,你就知道").Link("新 闻").Click
ip =
plugin.log.Entries.Item(0).ServerIP
''获取iP地址
code =
plugin.Log.Entries.Item(0).StatusCode ''获取状态码
linktime =
plugin.log.Entries.Summary.Time ''获取相应时间
If 10>linktime
Then
Reporter.ReportEvent micPass,"响应时间爱","少于10秒:"&linktime
else
Reporter.ReportEvent micFail,"响应时间","大于10秒:"&linktime
End If
If 400
>
code
Then
Reporter.ReportEvent micPass,
"状态码:"&code
else
Reporter.ReportEvent micFail,
"状态码:"&code
ExitAction
End If
'停止记录Http底层数据
plugin.Stop
'获取返回的状态码
''关闭浏览器窗口
plugin.CloseBrowser()
''回收对象
Set control=nothing
Set plugin=nothing
Set sumary=nothing
Dim
Dim
URL="
Set
Set
plugin.Log.EnableFilter(false)
plugin.Clear()
plugin.Record()
plugin.GotoURL(URL)
wait(2)
Browser("百度一下,你就知道").Page("百度一下,你就知道").Link("新
ip
code
linktime
If
Reporter.ReportEvent
else
Reporter.ReportEvent
End
If
Reporter.ReportEvent
else
Reporter.ReportEvent
ExitAction
End
'停止记录Http底层数据
plugin.Stop
'获取返回的状态码
''关闭浏览器窗口
plugin.CloseBrowser()
''回收对象
Set
Set
Set