|
对象库 vs 描述性编程, 建议大家好好看下QTP帮助里对描述性编程的阐述和定位
Using Programmatic Descriptions
When you record an operation on an object, QuickTest adds the appropriate test object to the object repository. Once the object exists in the object repository, you can add statements in the Expert View to perform additional methods on that object. To add these statements, you usually enter the name (not case sensitive) of each of the objects in the object's hierarchy as the object description, and then add the appropriate method.
For example, in the statement below, username is the name of an edit field. The edit field is located on a page with the name Mercury Tours and the page was recorded in a browser with the name Mercury Tours.
Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username")
Because each object in the object repository has a unique name, the object name is all you need to specify. During the test run, QuickTest finds the object in the object repository based on its name and parent objects, and uses the stored test object description for that test object to identify the object in your Web site or application.
You can also instruct QuickTest to perform methods on objects without referring to the object repository or to the object's name. To do this, you provide QuickTest with a list of properties and values that QuickTest can use to identify the object or objects on which you want to perform a method.
Such a programmatic description can be very useful if you want to perform an operation on an object that is not stored in the object repository. You can also use programmatic descriptions in order to perform the same operation on several objects with certain identical properties, or in order to perform an operation on an object whose properties match a description that you determine dynamically during the run session.
For example, suppose you are testing a Web site that generates a list of potential employers based on biographical information you provide, and offers to send your resume to the employer names you select from the list. You want your test to select all the employers displayed in the list, but when you design your test, you do not know how many check boxes will be displayed on the page, and you cannot, of course, know the exact object description of each check box. In this situation, you can use a programmatic description to instruct QuickTest to perform a Set "ON" method for all objects that fit the description: HTML TAG = input, TYPE = check box.
There are two types of programmatic descriptions. You can either list the set of properties and values that describe the object directly in a test statement, or you can add a collection of properties and values to a Description object, and then enter the Description object name in the statement.
Entering programmatic descriptions directly into your statements may be the easier method for basic object-description needs. However, in most cases, the Description object method is more powerful and more efficient. |
|