powerDebug

上一篇 / 下一篇  2011-02-18 10:55:15 / 个人分类:QTP

已然不是“最近”,呵呵,周末回家下载吧,公司。。

最近Tarun Lalwani发布了为QTP定制的第三方调试辅助工具 - PowerDebug 的Beta试用版:

http://knowledgeinbox.com/products/powerdebug/powerdebug-beta-now-available-for-download/

 

PowerDebug是QTP的一个插件调试器,提供一个调试IDE,并且增强了很多功能,例如调试那些用ExecuteFile、Execute和ExecuteGlobal加载的代码,增强了错误消息的显示、用断言点来暂停脚本执行等。

 

PowerDebug is a add-on debugger for QuickTest Professional. PowerDebug takes over the QTP debugging IDE and provides a new enhanced with many new features that QTP IDE doesn't have. Below is the list of features
·     Debug code loaded using statements ExecuteFile, Execute and ExecuteGlobal
·     Enhanced error messages with complete stack trace of the error
·     Pause execution using Assertion points
·     Enhanced command window with option to execute multiple line command
·     Enhanced output window with option to save the log to file
·     Implement Goto statements in code
·     Jump to any code statement during debugging
·     Accessing current scope information like FunctionName, Caller function and stack trace
·     Multi object existence check function to improve performance
 
 
参考:
http://blog.csdn.net/Testing_is_believing/archive/2010/04/19/5504266.aspx

发现陈某恰刚试用过,以下为其notes:

今天试用了一下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 thefunction- CallMe

[19-ËÄÔÂ-10|09:09:11] Thefunctionwas called by - IamCallingCaller

[19-ËÄÔÂ-10|09:09:11] The current codeis:

 

FunctionCallMe()

   '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

 

 

FunctionIamCallingCaller()

   CallCallMe()

End Function

 

 

CallIamCallingCaller

 

[19-ËÄÔÂ-10|09:09:11] The current stack traceis:

 

CallMe!Line (6):PowerDebug.Log("Currently inside the function - "& PowerDebug.FunctionName)

IamCallingCaller!Line (14):CallCallMe()

VBScript.globalcode!Line (18):CallIamCallingCaller

VBScript.globalcode!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"

 

 

 

5PowerDebugCommand窗口、Watch窗口、Variable窗口、Code窗口、Output窗口、CallStack窗口大大增强了QTP的调试能力和易用性。

 

 

6WaitForAllObjectExist方法

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的帮助文档,也可以参考作者主页上的文章

http://knowledgeinbox.com/products/powerdebug/enhancing-scripts-perfomance-using-waitforanyobjectexist/

 

 

 

试用PowerDebugBeta版本发现还不太稳定,有时候会停止响应。



TAG:

 

评分:0

我来说两句

Open Toolbar