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偵錯程式(學習筆記)筆記
- Xcode偵錯程式LLDBXCodeLLDB
- Python 偵錯程式入門Python
- PsySH作為偵錯程式
- 偵錯程式到底怎樣工作
- 反除錯 -- 利用ptrace阻止偵錯程式附加除錯
- Emacs 除錯祕籍之 GUD 偵錯程式Mac除錯
- 偵錯程式是個大騙子!
- Linux gdb偵錯程式用法全面解析Linux
- 另一個Swoole偵錯程式 - Yasd
- 自動化測試工具QTPQT
- Rails開發中使用byebug偵錯程式AI
- 在Docker內部使用gdb偵錯程式報錯-Operation not permittedDockerMIT
- tokio-rs/console:非同步 Rust 偵錯程式非同步Rust
- 如何在Docker內部使用gdb偵錯程式Docker
- 2.IDEA,Maven,偵錯程式的基本使用IdeaMaven
- 反除錯&反反除錯 -- 利用sysctl檢測偵錯程式是否存在除錯
- 為什麼在Docker裡使用gdb偵錯程式會報錯Docker
- 幽默:編寫Python程式碼你們使用什麼偵錯程式?Python
- taro使用手記
- 5 個鮮為人知 GNU 偵錯程式(GDB)技巧
- 優秀開發者必備技能包:Python偵錯程式Python
- SAP技術專家的ABAP偵錯程式培訓材料
- 如何從 ABAP 偵錯程式裡提取某個內表的內容用於單元測試
- WinRunner和QTP對比QT
- Process Hacker一款功能強大的系統偵錯程式
- tokio-rs/console:非同步Rust執行偵錯程式控制檯非同步Rust
- 在偵錯程式下看Panic機制及oops資訊分析OOP
- Windows 11 核心新偵錯程式「GitHub 熱點速覽 v.23.01」WindowsGithub
- RenderDoc圖形偵錯程式詳細使用教程(基於DirectX11)
- UE4藍圖AI角色製作(四)之Gameplay偵錯程式AIGAM
- 前端常用手寫程式碼前端
- 將Chrome偵錯程式裡的JavaScript變數儲存成本地JSON檔案ChromeJavaScript變數JSON
- 在偵錯程式下觀察Linux核心的資料包傳送過程Linux
- 深入理解python虛擬機器:偵錯程式實現原理與原始碼分析Python虛擬機原始碼
- Expert電子實驗室--嵌入式多功能偵錯程式Exlink硬體分析
- 一種快速過VMP3.x偵錯程式虛擬機器檢測的方法虛擬機
- 第3節 php-src 程式執行之入口函式main定位查詢與gdb偵錯程式1PHP函式AI
- web自動化測試(2):選擇selenium優勢?與PhantomJS/QTP/Monkey對比WebJSQT