QTP第三方偵錯程式PowerDebug試用手記
今天試用了一下PowerDebug的Beta版本,下面介紹一下PowerDebug的主要功能。
1、寫Log功能
在PowerDebug的輸出視窗寫Log。
例如:
'Clear the error
PowerDebug.ClearLog()
'Don't report Time to the output window
PowerDebug.ReportTimeInLog = False
PowerDebug.Log("This is a text Log without Time")
'Report Time to the output window
PowerDebug.ReportTimeInLog = True
PowerDebug.Log("This is a text Log with Time")
'Save the log to a file
PowerDebug.SaveLog("C:/Log.txt")
Dim varLog
'Returns the current text from the Log
varLog = PowerDebug.GetLog()
2、使用GoTo語句
PowerDebug allow you to use Goto Statements. The Goto method takes input the tag name. The tag need to be present with the Prefix and the Postfix. Consider the below code
(需要用字首和字尾指定GoTo跳轉到的標籤位置)
例如:
PowerDebug.GotoPrefix = "':"
PowerDebug.GotoPostfix = ":"
PowerDebug.Goto("JumpLocation")
MsgBox("This code should not be executed")
':JumpLocation:
MsgBox("Here after a jump")
'Goto statements can also be used to create a continue statement in a loop
For i = 0 To 10
If i > 5 And i < 8 Then
PowerDebug.Goto("ForContinue")
End If
PowerDebug.Log("Printing Loop counter - " & i)
':ForContinue:
Next
3、檢視當前程式碼執行環境
PowerDebug allows you to access current scope information which can be very useful for debugging information. The code sample below shows different information that can be accessed
例如:
Function CallMe()
'Load the current Scope information
PowerDebug.LoadInformation()
PowerDebug.Log("Currently inside the function - " & PowerDebug.FunctionName)
PowerDebug.Log("The function was called by - " & PowerDebug.Caller)
PowerDebug.Log("The current code is: " & vbCrLf & vbCrLf & PowerDebug.CurrentCode)
PowerDebug.Log("The current stack trace is: " & vbCrLf & vbCrLf & PowerDebug.StackTrace)
End Function
Function IamCallingCaller()
Call CallMe()
End Function
Call IamCallingCaller
上面的指令碼將輸出以下資訊:
[19-ËÄÔÂ-10|09:09:11] Currently inside the function - CallMe
[19-ËÄÔÂ-10|09:09:11] The function was called by - IamCallingCaller
[19-ËÄÔÂ-10|09:09:11] The current code is:
Function CallMe()
'Load the current Scope information
PowerDebug.LoadInformation()
PowerDebug.Log("Currently inside the function - " & PowerDebug.FunctionName)
PowerDebug.Log("The function was called by - " & PowerDebug.Caller)
PowerDebug.Log("The current code is: " & vbCrLf & vbCrLf & PowerDebug.CurrentCode)
PowerDebug.Log("The current stack trace is: " & vbCrLf & vbCrLf & PowerDebug.StackTrace)
End Function
Function IamCallingCaller()
Call CallMe()
End Function
Call IamCallingCaller
[19-ËÄÔÂ-10|09:09:11] The current stack trace is:
CallMe!Line (6):PowerDebug.Log("Currently inside the function - " & PowerDebug.FunctionName)
IamCallingCaller!Line (14):Call CallMe()
VBScript global code!Line (18):Call IamCallingCaller
VBScript global code!Line (1):RunAction "Action1", oneIteration
4、用Assert語句實現斷點
PowerDebug doesn't support QTP's breakpoint. So to pause execution or simulate a breakpoint one needs to use Assert method. Assert method when passed a False value pauses the execution
例如:
'Break execution on next statement
PowerDebug.Assert False
Print "The execution should be paused here"
5、PowerDebug的Command視窗、Watch視窗、Variable視窗、Code視窗、Output視窗、CallStack視窗大大增強了QTP的除錯能力和易用性。
6、WaitForAllObjectExist方法
PowerDebug提供的WaitForAllObjectExist方法可以用於判斷多個物件是否存在,而僅僅用一個語句:
bool WaitForAllObjectExist(int timeoutInSeconds, object obj1, [object obj2]....)
Returns true if all the passed objects exist within specified time, else returns false
例如:
Set obj1 = Window("regexpwndtitle:=File1.*")
Set obj2 = Window("regexpwndtitle:=File2.*")
'Wait for 10 seconds max for all objects to exist
Msgbox PowerDebug.WaitForAllObjectExist(10, obj1, obj2)
還有一個類似的方法是WaitForAnyObjectExist,用於判斷指定的若干個物件中是否有任意一個是存在的。關於該方法的使用可以參考PowerDebug的幫助文件,也可以參考作者主頁上的文章:
試用PowerDebug的Beta版本發現還不太穩定,有時候會停止響應。
相關文章
- GDB偵錯程式(學習筆記)筆記
- 微信偵錯程式
- [譯]來試試這個真正的 JavaScript 偵錯程式吧!JavaScript
- Xcode偵錯程式LLDBXCodeLLDB
- go語言偵錯程式Go
- 偵錯程式工作原理(三):除錯資訊除錯
- 偵錯程式工作原理(3):除錯資訊除錯
- Python 偵錯程式入門Python
- 偵錯程式到底怎樣工作
- PsySH作為偵錯程式
- 偵錯程式--jdb.exe(轉)
- Emacs 除錯祕籍之 GUD 偵錯程式Mac除錯
- 反除錯 -- 利用ptrace阻止偵錯程式附加除錯
- 另一個Swoole偵錯程式 - Yasd
- 偵錯程式是個大騙子!
- 使用GDB命令列偵錯程式除錯C/C++程式命令列除錯C++
- CodeBlocks偵錯程式設定錯誤問題BloC
- Linux gdb偵錯程式用法全面解析Linux
- iOS Debuger(便捷輔助偵錯程式)iOS
- 輕量級偵錯程式mimikatz
- 偵錯程式工作原理(1):基礎篇
- Linux 核心偵錯程式內幕(轉)Linux
- 用Watir測試QTP的Demo程式Mercury ToursQT
- Rails開發中使用byebug偵錯程式AI
- 如何在Docker內部使用gdb偵錯程式Docker
- 與偵錯程式共舞 – LLDB 的華爾茲LLDB
- 偵錯程式工作原理(2):實現斷點斷點
- C 語言偵錯程式是如何工作的?
- QTP測試Yahoo郵箱QT
- 在Docker內部使用gdb偵錯程式報錯-Operation not permittedDockerMIT
- 反除錯&反反除錯 -- 利用sysctl檢測偵錯程式是否存在除錯
- [轉發]RTH試用手記之“外場應用”
- 為什麼在Docker裡使用gdb偵錯程式會報錯Docker
- 2.IDEA,Maven,偵錯程式的基本使用IdeaMaven
- 揭秘Linux核心偵錯程式之內幕(轉)Linux
- 虛擬機器與偵錯程式的討論虛擬機
- linux下的c/c++偵錯程式gdbLinuxC++
- QTP測試QQ登入介面QT