什么时候使用DP?

通常在这些情况下需要使用到 DP Descriptive Programming :

    * Checking/Unchecking all Check Boxes on a web page

    * Setting all the Text Boxes to blank value

    * Selecting the first possible value for every WebRadioGroup

 

下面是一个使用的例子:

Dim oWebChkDesc

Set oWebChkDesc = Description.Create

oWebChkDesc("micclass").value = "WebCheckBox"

oWebChkDesc("html tag").Value = "INPUT"

 

'Get all objects matching this description

Dim allCheck, oCheckBox

Set allCheck = Browser("Web Tours").Page("Web Tours").ChildObjects(oWebChkDesc)

For i = 0 to allCheck.Count - 1

       Set oCheckBox = allCheck(i)

       oCheckBox.Set "ON"

Next

 

 

 



When and Why to use Descriptive programming?

http://knowledgeinbox.com/articles/qtp/descriptive-programming/dp-part-1-overview/

 

Below are some of the situations when Descriptive Programming can be considered useful:

 

1 The objects in the application are dynamic in nature and need special handling to identify the object. The best example would be of clicking a link which changes according to the user of the application, Ex. “Logout <>“. 对象动态变化,需要特殊处理来识别

 

2 When object repository is getting huge due to the no. of objects being added. If the size of Object repository increases too much then it decreases the performance of QTP while recognizing a object. 防止对象库过大导致 QTP 识别对象的性能下降

 

3. When you don’t want to use object repository at all. 不使用 OR 而使用 DP 的场景

Well the first question would be why not Object repository? Consider the following scenario which would help understand why not Object repository

Scenario 1 : Suppose we have a web application that has not been developed yet. Now QTP for recording the script and adding the objects to repository needs the application to be up, that would mean waiting for the application to be deployed before we can start of with making QTP scripts. But if we know the descriptions of the objects that will be created then we can still start off with the script writing for testing 可以在 AUT 未开发出来之前开始 QTP 的脚本编写

Scenario 2 : Suppose an application has 3 navigation buttons on each and every page. Let the buttons be “Cancel”, “Back” and “Next”. Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow this would mean 30 objects which could have been represented just by using 3 objects. So instead of adding these 30 objects to the repository we can just write 3 descriptions for the object and use it on any page. 减少添加重复的测试对象

 

4 Modification to a test case is needed but the Object repository for the same is Read only or in shared mode i.e. changes may affect other scripts as well. 采用共享对象库会影响脚本的并发开发

 

5 When you want to take action on similar type of object i.e. suppose we have 20 textboxes on the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the Object repository would not be a good programming approach. 需要对一组对象进行相同的操作时,用 DP 会比较方便

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值