你如何编写 QTP 测试?

发布于 2024-08-15 06:19:42 字数 99 浏览 4 评论 0 原文

我正在尝试使用 QTP 进行一些 webapp ui 自动化测试,我想知道人们通常如何编写 QTP 测试。您是否使用对象映射、描述性编程、组合或其他方式?任何小代码示例将不胜感激,谢谢

I am experimenting with using QTP for some webapp ui automation testing and I was wondering how people usually write their QTP tests. Do you use the object map, descriptive programming, a combination or some other way all together? Any little code example would be appreciated, Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七色彩虹 2024-08-22 06:19:42

这是我的建议。

1) 构建您的测试自动化需求矩阵。
您可以使用我的博客

http://automation 中的示例-beyond.com/2009/06/06/qa-test-automation-requirements-usability/

http://automation-beyond.com/2009/06/07/qa-test-automation-requirements-usability-2/

http://automation-beyond.com/2009/06 /10/qa-test-automation-requirements-5-maintainability/

http://automation-beyond.com/2009/06/08/qa-test-automation-requirements-robustness/

http://automation-beyond.com/2009/06/09/qa-test-automation-requirements-scalability /

2) 选择您的自动化方法

3 )根据您选择的方法编写测试脚本

注意。 QTP Repository 方式或描述性编程属于前端功能测试自动化的 GUI 识别部分。它们在坚固性和维护方面很重要。
从技术上来说,几乎是一样的。在这两种情况下,您都应该很好地理解 GUI 识别概念,否则无论采用哪种方法都会遇到问题。

  • 您可以将 GUI 对象识别属性存储在类似 XML 的数据结构中,并将记录映射到类似英语的名称。每当原始对象的属性发生更改时,您都会更新存储库中的记录,而代码仍然引用映射的名称。
  • 或者,您可以通过直接将相同的识别属性放入函数调用中来寻址 GUI 对象。每当原始对象的属性发生变化时,您就必须更改代码。但您不必随脚本一起维护额外的文件。

一个好的框架应该通过在对象引用级别操作来支持 GUI 映射和描述性编程符号。也就是说,您应该将对象识别和对象交互任务分开。

请注意,根据上下文,描述性编程符号可能减慢脚本的性能,并且它总是需要额外的维护工作,而在其他情况下,仅使用对象存储库可能会导致对象描述不必要的重复,或者可能会限制对动态更改的 GUI 的识别。
我在下面的文章中阐述了上面提出的一些观点:
一些 QTP 性能测试:对象存储库与描述性编程

直接代码示例(对于实际的自动化,我推荐 GUI 函数换行)。

描述性编程 - 通过物理描述属性来寻址对象。

Dim sProfile
sProfile = "Guest"

Set objWebParent = Browser("title:=Select Profile").Page("title:=Select Profile")
Set objWebObject = objWebParent.Link("text:="&sProfile) 
boolRC = objWebObject.Exist(0) 
If Not boolRC Then
'error-handling
End If
objWebObject.Click

通过映射的 GUI 名称来寻址对象

Browser("Select Profile").Page("Select Profile").Link("Guest").Click

谢谢,
阿尔伯特·加里耶夫
http://automation-beyond.com/

Here's my suggestion.

1) Build your test automation requirements matrix.
You can use samples from my blog

http://automation-beyond.com/2009/06/06/qa-test-automation-requirements-usability/

http://automation-beyond.com/2009/06/07/qa-test-automation-requirements-usability-2/

http://automation-beyond.com/2009/06/10/qa-test-automation-requirements-5-maintainability/

http://automation-beyond.com/2009/06/08/qa-test-automation-requirements-robustness/

http://automation-beyond.com/2009/06/09/qa-test-automation-requirements-scalability/

2) Choose your automation approach

3) Write your testing scripts according to the approach you chose

Note. QTP Repository way or Descriptive Programming belong to GUI recognition part of front-end functional test automation. They matter in terms of robustness and maintenance.
Technically, it's nearly the same. In both cases you should understand GUI recognition concept well, or you will have problems no matter the approach.

  • You can store GUI object recognition properties in XML-like data structure and map the record to an English-like name. Whenever the original object's properties change, you update your record in repository, while a code still refers to a mapped name.
  • Or you can address GUI objects by directly putting same recognition properties into a function call. Whenever the original object's properties change, you have to do code change. But you don't have to maintain extra files along with your scripts.

A good framework should support both GUI-mapped and descriptive programming notations by operating at object reference level. I.e. you should keep object recognition and object interaction tasks separate.

Note that depending on context Descriptive Programming notation may slowdown performance of your scripts and it always demands extra maintenance effort while in other cases using Object Repositories only may lead to unwanted duplication of objects' descriptions or it may limit recognition of dynamically changing GUI.
I illustrate some points made above in the following article:
A little QTP performance test: Object Repository vs. Descriptive Programming

Straight code examples (for a practical automation I recommend GUI Function Wrapping).

Descriptive programming - addressing objects by physical description properties.

Dim sProfile
sProfile = "Guest"

Set objWebParent = Browser("title:=Select Profile").Page("title:=Select Profile")
Set objWebObject = objWebParent.Link("text:="&sProfile) 
boolRC = objWebObject.Exist(0) 
If Not boolRC Then
'error-handling
End If
objWebObject.Click

Addressing objects by mapped GUI names

Browser("Select Profile").Page("Select Profile").Link("Guest").Click

Thank you,
Albert Gareev
http://automation-beyond.com/

哎呦我呸! 2024-08-22 06:19:42

我知道我来晚了,您一定已经找到了您想要的东西,但我也想为访问此主题的任何人提供我的意见。

我通常从不使用 OR,除非遇到描述性编程不可行的环境。就在最近,我使用了一个大型机前端 GUI 应用程序,该应用程序完全没有对象命名约定。如果您选择对此类应用程序使用描述性编程,则处理其对象的唯一方法是通过索引或位置序号标识符,考虑到每个窗格中有 100 个对象,这不是最佳操作方案。

因此,您问题的答案实际上取决于环境以及您使用 OR 和 DP 的经验。在我的工作中和在线社区中与我共事的大多数人都喜欢在可行的情况下使用描述性编程。然而,我也看到人们用 OR 创造了奇迹。

我有一些代码示例,但不幸的是,它们涉及描述性编程。例如,以下文章讨论了创建模块化 VBScript 类以将应用程序的功能划分为小的可管理组件:

http://relevantcodes.com/qtp-using-classes-as-test-modules-i/

同样,本文展示了如何使用描述性编程来验证目标对象的多个属性通过单个代码块:

http://relevantcodes。 com/qtp-verify-multiple-object-properties-an-elegant-approach/

另外,您还可以在此处查看演示框架:

http://relevantcodes.com/relevantcodes1one-qtp-automation-framework/

该框架完全基于描述性编程的原则构建,但在下一个版本中,将添加一些功能,使用户也可以使用 OR。

谢谢你,

Anshoo Arora

(感谢 Motti 链接到原始文章)

I know I am late here, and you must already have what you are looking for, but I wanted to provide my inputs as well for anyone visiting this topic.

I generally never use OR, unless I encounter an environment where Descriptive Programming is a no-go. Just recently, I worked with a Mainframe Front-End GUI application that has absolutely no naming convention for objects. If you choose to use Descriptive Programming with such an application, the only way to work with its objects would be through Index or Location Ordinal Identifiers, which is not the best course of action considering 100's of objects in each pane.

So, the answer to your question really depending upon the environment and your experience with OR and DP. Most people I have worked with at my job, and on online communities prefer to work with Descriptive Programming whenever its feasible. However, I have also seen people work wonders with OR.

I have a few code samples, but, unfortunately, they are deal with Descriptive Programming. For instance, the following article talks about creating modular VBScript classes to divide application's functionality into small manageable components:

http://relevantcodes.com/qtp-using-classes-as-test-modules-i/

Similarly, this article shows how Descriptive Programming can be used to verify multiple properties of target objects through a single block of code:

http://relevantcodes.com/qtp-verify-multiple-object-properties-an-elegant-approach/

Also, a demo framework is also available for you to view here:

http://relevantcodes.com/relevantcodes1one-qtp-automation-framework/

The framework is built completely on the principles of Descriptive Programming, but in the next release, some functionality will be added that will enable users to work with ORs as well.

Thank you,

Anshoo Arora

(Thanks for linking to the original articles, Motti)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文