首页 测试 工具 查看内容

规避QTP等待缺陷的一个函数

2014-8-30 12:43| 发布者: | 查看: 451| 评论: 0

摘要:   QTP等待有一定的缺陷,因此编写如下函数。  函数功能嘛,呵呵。各自发挥吧。有很多的用法哦。  _________________________________________________________________________  ''  /******************* ...

  Public Function WaitExcept(expectOrder,sWaitTime)

  On Error Resume Next

  Err.Clear

  '变量为:记录运行时间,匹配预期值的变量

  Dim totalTime,bolExist,bolCheck

  bolExist = False '默认表达式的值为false

  Execute "bolCheck = " & expectOrder  '给expectItem获取要匹配的值

  If Err.Number <> 0 Then

  bolCheck = False

  Err.Clear

  End If

  totalTime = 0

  Do while not  bolCheck  '如果语句运行结果不为True

  wait 0,100 '等待500毫秒

  totalTime =CDbl(totalTime) + 0.1 '记录等待的秒数

  If CDbl(totalTime) > CDbl(sWaitTime) Then '超过配置的时间就报超时

  Reporter.ReportEvent micWarning,"页面显示",expectOrder  & "--超时"'记录超时信息到报告

  bolExist = False'如果超时,则认为表达式的值为false

  Exit Do

  End If

  Execute "bolCheck = " & expectOrder  '重新给expectItem获取要匹配的值

  If Err.Number <> 0 Then

  bolCheck = False

  Err.Clear

  End If

  Loop

  If bolCheck Then  '如果表达式的值为True

  bolExist = True

  End If

  WaitExcept = bolExist '返回表达式的值的情况

  On Error Goto 0

  End Function

 

  QTP等待有一定的缺陷,因此编写如下函数。

  函数功能嘛,呵呵。各自发挥吧。有很多的用法哦。

  _________________________________________________________________________

  ''

  /*******************Function**************************/

  '* 功能:等待语句为True值,如果超过预设的时间,则记入报告,退出测试

  '* 输入参数:expectOrder:希望为True的语句

  '* sWaitTime :等待的时间,单位为秒

  '* 返回值:bool值,如果值等于预期,则返回true,否则返回false

  '* 编写人:chenyb

  '* 编写日期:2008-12-30

  '* 其他说明:可以传入一个表达式,等待这个表达式的值为True

  '/********************************************************/


鲜花

握手

雷人

路过

鸡蛋

扫一扫关注最新动态

毒镜头:老镜头、摄影器材资料库、老镜头样片、摄影
爱评测 aipingce.com  
返回顶部