使用QTP进行WEB页面性能测试

本文介绍了一种使用QTP进行网页性能测试的方法。通过创建InternetExplorer.Application对象并导航到指定URL,利用ReadyState属性监测页面加载状态。脚本记录了不同阶段的时间,包括初始化、发送请求、接收响应数据及页面加载完成等过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

QTP是功能测试工具,但是也可以用于WEB页面的性能测试,下面脚本利用了IE的COM接口和DOM获取ReadyState的方式来测试WEB页面加载的性能:

 

SiteURL = "http://blog.youkuaiyun.com/testing_is_believing" 'Set the URL to visit
result = timeCount (SITEURL) 'returns running results
MsgBox result 'output to run As a result, the line can be commented out loadrunner


Public Function timeCount (url)
 Set dom = CreateObject ( "InternetExplorer.Application") 'Create an IE object
 dom.Navigate (url) 'open the specified URL
 time_start = Now () 'to obtain statistics at the beginning of time
 timer_start = timer () 'Get the current time in milliseconds
 'a = dom.ReadyState' Get the current state of the value of IE will be used to determine the value of the state of the current state of the IE
 dom.visible = True 'Set IE can be seen
 While dom.busy or (dom.readyState <> 4) 'When the IE is in BUSY status or load does not complete (readystate is not equal to 4), depending on the state of IE statistical time, once every millisecond Statistics
  'WScript.Sleep 1 'time interval 1 ms, if the relatively long time interval, then is likely to take less than a state value
        Wait 0, 1
  Select Case dom.readystate 'to determine the value of dom.readystate
   Case 0 'IE is not initialized, in fact, the method, readystate = 0 meaningless, because the cycle is at least a start.
    time0 = Now ()
    timer0 = timer ()
   Case 1 ' "is sending request"
    time1 = Now ()
    timer1 = timer ()
   Case 2 ' "request has been sent to complete"
    time2 = Now ()
    timer2 = timer ()
   Case 3 ' "can receive the part of the response data,"
    time3 = Now ()
    timer3 = timer ()
   Case 4 ' "Page is loaded"
    time4 = Now ()
    timer4 = timer ()
  End select
 wend
 time_end = Now () 'Statistical End Time
 'MsgBox "Start time is:" & time1 & "; the end of time is" & time2
 timeCount = "Statistics Start Time:" & start_time & vbcrlf & "time0:" & time0 & vbcrlf & "time1:" & time1 & vbcrlf & "time2: "_
       & time2 & vbcrlf &" time3: "& time3 & vbcrlf &" time4: "& time4 & vbcrlf &" to complete the initialization of IE and send request:  "_
       & (timer1-timer_start) &" seconds "& vbcrlf &" to send the completion and acceptance of server-side part of the response data:  "_
       & (timer3-timer1) &" seconds "& vbcrlf &" 100% to receive and complete the HTML content parsing: "_
       & (timer4-timer3) &" seconds "& vbcrlf &" Total spent: "& (timer4-timer_start) &" seconds "
End Function

 

参考:

http://www.qtp10.com/2009/12/web-application-performance-testing.html

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值