您如何编写 QTP 测试? [英] How do you write your QTP Tests?

查看:25
本文介绍了您如何编写 QTP 测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 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

推荐答案

这是我的建议.

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

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) 选择您的自动化方法

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

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

注意. QTP Repository方式或Descriptive Programming属于前端功能测试自动化的GUI识别部分.它们在稳健性和维护方面很重要.从技术上讲,它几乎相同.在这两种情况下,您都应该很好地理解 GUI 识别概念,否则无论哪种方法都会出现问题.

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.

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

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

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.

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

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

直接代码示例(对于实用的自动化,我推荐 GUI 函数包装).

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

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

Addressing objects by mapped GUI names

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

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

这篇关于您如何编写 QTP 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆