本地对象库与共享对象库理解

上一篇 / 下一篇  2011-02-14 14:20:46 / 个人分类:QTP

Work with Test Object

Object repository:

一般来讲,测试对象都是保存在库里面,库又可以分为本地库和共享库,那么该如何选择恰当的库来保存测试对象呢?

 

在创建一个简单的测试的时候经常使用的库是本地对象库,尤其一下情况:

1.        针对一个指定的程序,接口或者对象设置的时候,录制一个很少测试的时候;

2.        不需要频繁修改对象属性是;

3.        创建单一操作测试时;

相反在下一情况下建议使用共享对象库:

1.        使用关键字驱动测试技术创建测试时;

2.        包含多个测试程序,接口或对象设置的多个测试时;

3.        需要实施修改测试对象的属性或有规律的更新测试对象属性是;

4.        经常进行多个测试和有规律的使用“Insert Copy of Action”和“Insert Call to Action”时;

 

如何理解本地对象库?

1.        QTP正对动作创建的一个新的对象库;

2.        QTP获得这些新的对象的时候,会自动保存这些对象的信息到指定的本地对象库中,当共享数据库和这些新的对象存在一定关系时,QTP依然会把新的对象添加到本地对象库中;

3.        当一个子对象被添加到本地对象库中,而父对象在共享对象库中时,QTP会自动的把共享库中的父对象异动到本地对象库中;

4.        QTP在每次创建一个新的动作的时候,QTP会创建一个新的,指定的对象库并把这个新的测试对象保存在这个库中;

5.        QTP在录制测试的时候,在不同的测试步骤中,遇到两个相同的测试对象,QTP会保存两个不同的测试对象到每一个对应的本地对象库中;

6.        在保存测试的时候,本地对象库会一起被保存到这个测试中,不能单独保存;

 

如何理解共享对象库呢?

对于指定的动作,QTP会使用一个或多个共享对象库。在创建测试的时候,你可以指定一个共享对象库,也可以新建一个与之相关的共享对象库。在运行这个测试前必须保证你的测试中使用的共享对象库包含了所有的测试对象,否则运行失败。

编辑共享对象库可以使用Object Repository Manager工具。共享对象库具有以下的属性:

1.        QTP在获取一个已经存在共享库或本地库中的对象的时候,它会利用这些信息,而不会将该对象加入到对象库中;

2.        当子对象被保存在本地对象库时,父对象如果在共享对象库,QTP会自动将父对象转移到本地对象库中;

3.        QTP在获取测试对象的时候,首先会将对象添加本地对象库中,除非这个对象已经存在共享数据中;

本地对象库可以被导出到共享对象库中,也可以替换共享对象库;对于相同的动作的对象,QTP可以直接把本地对象库的对象合并到共享数据库中。

 

Local object Repository >Object Repository > only the specific component can access the stored objects.

Notes: If you modify an object in the local object repository, your changes do not have any effect on any other component

 

Shared object repository>Object Repository Manager> can be accessed by multiple components

Notes: You can update them in one location for all the components that use this shared object repository.

 

 

Local objects are saved locally with the component, and can be accessed only from that component. When using a shared object repository, you can use the same object repository for multiple components. You can also use multiple object repositories for each component.

 

 

Deciding Whether to Use Local or Shared Object Repositories

 

 

Local Object Repositories

Few components

Not frequently modify test object properties

 

1.        QTP create new object repository for each component

2.        QTP automatically stores the information with objects if the objects not exist in an associated shared object repository.

3.        QTP add new objects to local object repository even if one or more shared object repositories are already associated with the component. Assumes object not exist the associated shared object.

4.        If a child object is added to a local object repository, and its parents are in shared object repository, its parents are automatically moved to the local object repository.

5.        When you save your component, the local object repository is automatically saved with it.

 

 

Shared Object Repositories

Creating components using keyword-driven methodologies

1.        If you record operations on an object that already exists in either the shared or local object repository, QTP uses the existing information and does not add the object to the object repository.

2.        If a child object is added to a local object repository, and its parents are in a shared object repository, its parents are automatically moved to the local object repository.

 

Associated with the selected component

Local objects are editable (black); shared objects are in read-only format (gray)

 

This dialog box lists the object repository files associated with all the actions in the current test. You can change the associations and perform. other administrative tasks.

 

Delete object

You can delete objects from the local object repository using the Object Repository window. You can delete objects from a shared object repository using the Object Repository Manager. For more information

 

Filter toolbar list, filter function.

 

 

1.        Copy an object to the local object repository, its parent objects are also copied to the local object repository.

2.        If an object or its parent objects use unmapped repository parameters, you cannot copy the object to the local object repository, make sure all repository parameters are mapped before copy.

3.        If an object or its parent objects are parameterized using one or more repository parameters, the repository parameter values are converted when you copy the object to the local object repository.

4.        If you are copying multiple objects to the local object repository, during the copy process you can choose to skip a specific object if it has unmapped repository parameters, or if it has mapped repository parameters whose values you do not want to convert. You can then continue copying the next object from your original selection.

 

Object Properties and Property values—description properties, ordinal identifier, and additional details.

 

 

Edit > Step Properties > Object Properties.

 

Test object Details >Restore mandatory property set

 

 

Renaming Test Objects

 

 

If you do not want to automatically update test object names for all occurrences of the test object, you can clear theAutomatically update test and component steps when you rename test objectscheck box in the General tab of the Options dialog box (Tools > Options). If you clear this option, you will need to manually change the test object names in all steps in which they are used, otherwise your component run will fail.

 

 

Define new property

 

Mapping repository parameter value??

 

Locating an object in the object repository

 

Export local objects to a new shared object repository = a file with a.tsrextension

 

 

Test object classes:

Standard Windows

Visual Basic

Web

 

Ordinal identifier

Note: You cannot include the same property in both the mandatory and assistive property lists

 

Reset Test Object: the system default.

Reset Environment: the system default.

Reset ALL

 

 

Managing Object Repositories

 

 

Working with Repository Parameters ?

Managing Repository Parameters

The Manage Repository Parameters dialog box enables you to add, edit, and delete repository parameters for a single shared object repository.

Clear default value button.


TAG:

 

评分:0

我来说两句

Open Toolbar