On Error Resume Next
QTP採用VBS作為指令碼語言,VBS中處理錯誤的語句是:
On Error Resume Next
On Error GoTo 0
If you don't use an On Error Resume Next statement anywhere in your code, any run-time error that occurs can cause an error message to be displayed and code execution stopped. However, the host running the code determines the exact behavior. The host can sometimes opt to handle such errors differently. In some cases, the script debugger may be invoked at the point of the error. In still other cases, there may be no apparent indication that any error occurred because the host does not to notify the user. Again, this is purely a function of how the host handles any errors that occur.
Within any particular procedure, an error is not necessarily fatal as long as error-handling is enabled somewhere along the call stack. If local error-handling is not enabled in a procedure and an error occurs, control is passed back through the call stack until a procedure with error-handling enabled is found and the error is handled at that point. If no procedure in the call stack is found to have error-handling enabled, an error message is displayed at that point and execution stops or the host handles the error as appropriate.
On Error Resume Next causes execution to continue with the statement immediately following the statement that caused the run-time error, or with the statement immediately following the most recent call out of the procedure containing the On Error Resume Next statement. This allows execution to continue despite a run-time error. You can then build the error-handling routine inline within the procedure.
An On Error Resume Next statement becomes inactive when another procedure is called, so you should execute an On Error Resume Next statement in each called routine if you want inline error handling within that routine. When a procedure is exited, the error-handling capability reverts to whatever error-handling was in place before entering the exited procedure.
Use On Error GoTo 0 to disable error handling if you have previously enabled it using On Error Resume Next.
The following example illustrates use of the On Error Resume Next statement.
On Error Resume Next Err.Raise 6 ' Raise an overflow error. MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description Err.Clear ' Clear the error.
Err物件包含執行時的錯誤資訊。
Raise方法用於產生執行時錯誤
Clear方法用於清除執行時錯誤。
Description屬性儲存了錯誤相關的描述資訊。
Number屬性是指錯誤號。
Source屬性是指產生錯誤的源頭物件或應用程式名。
The Err object is an intrinsic object with global scope — there is no need to create an instance of it in your code. The properties of the Err object are set by the generator of an error — Visual Basic, an Automation object, or the VBScript programmer.
The default property of the Err object is Number. Err.Number contains an integer and can be used by an Automation object to return an SCODE.
When a run-time error occurs, the properties of the Err object are filled with information that uniquely identifies the error and information that can be used to handle it. To generate a run-time error in your code, use the Raise method.
The Err object's properties are reset to zero or zero-length strings ("") after an On Error Resume Next statement. The Clear method can be used to explicitly reset Err.
The following example illustrates use of the Err object:
On Error Resume NextErr.Raise
6 ' Raise an overflow error. MsgBox ("Error # " & CStr(Err.Number
) & " " &Err.Description
)Err.Clear
' Clear the error.
在QTP中除了使用VBS的On Error Resume Next來處理錯誤外,還可以採用以下兩種方式來處理:
1、設定Test Settings中的“When error occurs during run session”
By default, if an error occurs during the run session, QuickTest displays a popup message box describing the error. You must click a button on this message box to continue or end the run session.
You can accept the popup message box option or you can specify a different response by choosing one of the alternative options in the list in the When error occurs during run session box:
QuickTest first performs any recovery scenarios associated with the test, and performs the option selected above only if the associated recovery scenarios do not resolve the error.
2、設定恢復場景(Recovery Scenario)
http://blog.csdn.net/Testing_is_believing/archive/2008/03/17/2193021.aspx
相關文章
- 利用On Error Resume Next來驗證日期的輸入(ASP 3.0) (轉)Error
- android Activity的onPause()與onResume()Android
- 【Mysql】Last_Error: 1778 @@SESSION.GTID_NEXT == 'UUID:NUMBER'.MySqlASTErrorSessionUI
- EFResume 一個普通的 Swift 簡歷模板Swift
- Alter system suspend/resume 導致的bug和特性
- Java多執行緒之過時的suspend 與 resumeJava執行緒
- ResumeGo:LinkedIn如何影響求職者的面試機會Go求職面試
- flutter中實現仿Android端的onResume和onPause方法FlutterAndroid
- Android setUserVisibleHint-- fragment真正的onResume和onPause方法AndroidFragment
- yield next和yield* next的區別
- jQuery next()jQuery
- # Scanner:區別next和nextLine
- Win10系統開機提示“Resume from Hibernation”如何解決Win10
- jQuery nextUntil()jQuery
- jQuery nextAll()jQuery
- jQuery prev + nextjQuery
- next-route
- next_permutation
- Next.js+React聊天室|Next仿微信桌面端|next.js聊天例項JSReact
- 您真的懂fragment的onResume,setUserVisibleHint,onHiddenChanged,isVisible方法嗎!Fragment
- eslint-disable-next-line to ignore the next lineEsLint
- mount error(5): Input/output errorError
- 【ERROR】OPatch failed with error code 73ErrorAI
- error:slave communication error with ASMErrorASM
- ERROR: slave communication error with ASMErrorASM
- 筆記-nextTick筆記
- hexo next主題Hexo
- OpenSourceNextGenerationIntrusionDetectionandPreventionEngineNaN
- 090 $nextTick
- WPF Image automatically display image via System.Timers.Timer ,pause and resume, scaletransformORM
- Hexo+NexT(零):最全Hexo+Next搭建部落格教程Hexo
- Next.js踩坑入門系列(一)— Hello Next.js!JS
- MMON encountered error 959, clearing the errorError
- 如何解決"Parse error: syntax error"Error
- 00022.08 Scanner的next()和nextLine()區別
- KMP演算法的next、next value陣列的手工計算KMP演算法陣列
- nextcloud個人雲搭建Cloud
- vue中的nextTickVue