QTP第三方调试器PowerDebug试用手记

2024-03-26 05:38

本文主要是介绍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"

 

 

 

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版本发现还不太稳定,有时候会停止响应。

 

 

这篇关于QTP第三方调试器PowerDebug试用手记的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/847438

相关文章

服务器集群同步时间手记

1.时间服务器配置(必须root用户) (1)检查ntp是否安装 [root@node1 桌面]# rpm -qa|grep ntpntp-4.2.6p5-10.el6.centos.x86_64fontpackages-filesystem-1.41-1.1.el6.noarchntpdate-4.2.6p5-10.el6.centos.x86_64 (2)修改ntp配置文件 [r

如何更优雅地对接第三方API

如何更优雅地对接第三方API 本文所有示例完整代码地址:https://github.com/yu-linfeng/BlogRepositories/tree/master/repositories/third 我们在日常开发过程中,有不少场景会对接第三方的API,例如第三方账号登录,第三方服务等等。第三方服务会提供API或者SDK,我依稀记得早些年Maven还没那么广泛使用,通常要对接第三方

SW - 引入第三方dwg图纸后,修改坐标原点

文章目录 SW - 引入第三方dwg图纸后,修改坐标原点概述笔记设置图纸新原点END SW - 引入第三方dwg图纸后,修改坐标原点 概述 在solidworks中引入第三方的dwg格式图纸后,坐标原点大概率都不合适。 全图自动缩放后,引入的图纸离默认的原点位置差很多。 需要自己重新设置原点位置,才能自动缩放后,在工作区中间显示引入的图纸。 笔记 将dwg图纸拖到SW中

JAVA学习-练习试用Java实现“删除有序数组中的重复项”

问题: 给你一个有序数组 nums ,请你 原地 删除重复出现的元素,使每个元素 只出现一次 ,返回删除后数组的新长度。 不要使用额外的数组空间,你必须在 原地 修改输入数组 并在使用 O(1) 额外空间的条件下完成。 说明: 为什么返回数值是整数,但输出的答案是数组呢? 请注意,输入数组是以「引用」方式传递的,这意味着在函数里修改输入数组对于调用者是可见的。 你可以想象内部操作如下

Node.js和vue3实现GitHub OAuth第三方登录

Node.js和vue3实现GitHub OAuth第三方登录 前言 第三方登入太常见了,微信,微博,QQ…总有一个你用过。 在开发中,我们希望用户可以通过GitHub账号登录我们的网站,这样用户就不需要注册账号,直接通过GitHub账号登录即可。 效果演示 注册配置 GitHub 应用 1.首先登录你的GitHub然后点击右上角的头像->点击进入Settings页面 2.在

JAVA学习-练习试用Java实现“N皇后 II”

问题: n 皇后问题研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。 给定一个整数 n ,返回 n 皇后问题不同的解决方案的数量。 示例 1: 输入:n = 4 输出:2 解释:如上图所示,4 皇后问题存在两个不同的解法。 示例 2: 输入:n = 1 输出:1 提示: 1 <= n <= 9 皇后彼此不能相互攻击,也就是说:任何两个皇后都不能处于同

QTP基本使用

QTP的基本使用方法 QTP对于非专业技术人员,提供了较为简单的录制和关键字操作界面。普通业务测试人员,也能够较容易地利用QTP进行一些简单的自动化测试工作。 步骤一:录制脚本   点击Record就开始录制脚本,当然可以先设置一下,在Automation-->Record and run settings中。一般使用基本录制模式。 步骤二:回放脚本   点击Run就

试用GLFW并创建OpenGL和DX的环境

介绍GLFW GLFW官网:https://www.glfw.org/ GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan development on the desktop. It provides a simple API for creating windows, contex

试用UE4的纹理数组(UTexture2DArray)

UTexture2DArray 我发现在我目前使用的版本(4.25)中,官方已经实现了纹理数组(可能在4.24或更早版本就已经实现了)。 纹理数组,其含义不言而喻。一个重要作用是可以使用更多的纹理而不受制于sampler数目限制。 这一篇里我想对官方的纹理数组进行一下简单的试用。 试用 0. 启用纹理数组 虽然我看到了代码中有UTexture2DArray这个类,不过一开始并没有在编辑器

试用 Houdini Engine Python API

介绍 hapi 这个python包 是HoudiniEngine的一层python封装。 使用python的优势是灵活性,因为C代码总需要编译,使得迭代较慢。 Tips: hapi中的内容总可以查阅HoudiniEngine的文档,因为概念和函数是相同的。 使用环境 1. Houdini编辑器内:Python Shell 在其中可以 import hapi: 2. Houd