zoukankan      html  css  js  c++  java
  • TestPartner脚本错误处理的例子

    The following test script is an example of TestPartner as well as VBA error handling:

    Sub Main()

      On Error Resume Next

      Dim oe As TOnError
      Set oe = OnError("MyErrorFunction")

      ' Attach to Program Manager Window
      Window("Program Manager Window").Attach

      ' Try to perform the bitmap select and get the return code.
      ' Since this a failure of a method, TestPartner can control
      ' the creation of the error condition using TestPartner's
      ' error mechanism.
      Dim b As Boolean
      b = Window.BitmapSelect("MetapadIcon")
      MsgBox "Return from BitmapSelect = " & CStr(b)

      ' This statement will require the VBA version of the On Error
      ' handler because the Window() statement returns an object that
      ' will be used to Attach.  If the object is not created because
      ' the attach name could not be found in the object map, VBA
      ' generates an error so the message has to be trapped.
      On Error GoToObjectErrorSub
      b = Window("this object map does not exist").Attach
      MsgBox "Return from Window.Attach = " & CStr(b)

    Exit Sub

    ObjectErrorSub:

      ' Display and/or handle VBA error
      MsgBox "Err.Number = " & CStr(Err.Number) & vbCrLf & _
      "Err.Source = " & Err.Source & vbCrLf & _
      "Err.Description = " & Err.Description
      Resume Next

    End Sub

    Function MyErrorFunction() As tpOnErrorType

      ' Display an error
      MsgBox "Message = " & Error.Message & vbCrLf & _
      "Function = " & Error.Function & vbCrLf & _
      "SourceFile = " & Error.SourceFile & vbCrLf & _
      "SourceLine = " & CStr(Error.SourceLine)

      ' Tell TestPartner that it should execute the next statement
      MyErrorFunction = tpResumeNext

    End Function

  • 相关阅读:
    dom2级事件兼容性写法
    cookie js案例
    cookie讲解
    js高级总结
    鼠标拖拽时,选择文字问题
    正则的细节
    正则捕获的细节及replace分析
    正则的使用及replace细讲
    while循环的讲解
    acwing 189. 乳草的入侵 bfs
  • 原文地址:https://www.cnblogs.com/testware/p/2010008.html
Copyright © 2011-2022 走看看