正文

managing objects

(2011-06-29 12:32:54) 下一个

Managing Objects

Note: The functionality described in this section is available in the Object Repository window for the local object repository, and the Object Repository Manager for shared object repositories.

Adding, Defining, Deleting, Copying Test Objects
1. Adding and Deleting Test Objects in a Local or Shared Object Repository
You can use the Navigate and Learn option, for example, to add objects to the shared object repository according to your defined filter. If you record a test, QuickTest adds each object on which you perform an operation to the local object repository (for objects that do not already exist in an associated shared object repository). You can also add test objects to the local object repository while editing your test.
Task: Add object to repository from Active Screen
If the object you select in the Object Selection dialog box is a parent (container) object, such as a browser the Define Object Filter dialog box opens.
Add test objects from a local or shared object repository to your test.

2. Defining New Test Objects
You can define test objects in your object repository that do not yet exist in your application. This enables you to prepare an object repository and build tests for your application before the application is ready for testing.
Task: Define a new test object--login name Webedit.

3. Deleting Objects in the Object Repository
When you remove a step from your test, its corresponding object remains in the object repository.If your action contains references to an object that you deleted from the object repository, your test run will fail.

4. Guidelines for Copying, Pasting, and Moving Objects
You cannot modify the root node of an object repository.
If you change the object hierarchy, ensure that the new hierarchy is valid.
If you paste or move an object to a different hierarchical level, you can choose whether to copy all objects up to the shared parent object (in the message displayed when you perform such an operation).
In the Object Repository window, when you copy, paste, and move objects from a shared object repository associated with a test, the objects are copied, pasted, or moved to the local object repository of the test.
If you move an object to its immediate parent, QuickTest creates a copy of the object and pastes it as a sibling of the original object.
If you cut or copy an object, and then paste it on its parent object, QuickTest creates copy of the object and inserts it at the same level as the original object.
You cannot move an object to any of its descendants.

Locating Objects

1. Finding Objects in an Object Repository.You can use the Find and Replace dialog box to find an object, property, or property value in an object repository.

2. Highlighting an Object in Your Application.

3. Locating a Test Object in the Object Repository.

Maintaining Identification Properties

1. Updating Identification Properties from an Object in Your Application
2. Restoring Default Mandatory Properties for a Test Object
If you added or removed properties to or from the description, those changes are overwritten. However, if property values were defined or modified for any of the mandatory properties, those values are not modified when you choose this option.

3. Renaming Test Objects
Renaming a test object does not affect the way QuickTest recognizes the object in your application, as the test object name is not included in the test object description.
If you are working with a shared object repository, your change applies to all occurrences of the test object in all tests that use this shared object repository.
If you are working with a local object repository, your change applies to all occurrences of the test object in the selected action.

4. Adding Properties to a Test Object Description
Defining New Identification Properties;
Ordinal Identifiers
An ordinal identifier assigns a numerical value to a test object that indicates its order or location relative to other objects with an otherwise identical description (objects that have the same values for all properties).

5. Visual Relation Identifiers
A visual relation identifier is a set of definitions that enable you to identify the object in the application according its neighboring objects in the application.

Working with Your Test's Object Repositories

1. Exporting Local Objects to a Shared Object Repository
The Export and Replace Local Objects option exports the local objects to a shared object repository, associates the new shared object repository with your action, and deletes the objects in the local object repository.

2. Copy an Object to the Local Object Repository





Retrieving Native Properties

You can use the Object property to access the native properties of any run-time object. For example, you can retrieve the current value of the ActiveX calendar’s internal Day property as follows:
Dim MyDay
Set MyDay= Browser("index").Page("Untitled").ActiveX("MSCAL.Calendar.7").Object.Day

Activating Native Operations
You can use the Object property to activate the internal operations of any run-time object. For example, you can activate the native focus method of the edit box as follows:
Dim MyWebEdit
Set MyWebEdit=Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Object
MyWebEdit.focus


Descriptive Programming:

Static:

Open the Register link without using href property. Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Link("text:=REGISTER").Click


Using object index:
If you use an index value of 3 to describe a WebElement object, however, QuickTest searches for the fourth Web object on the page regardless of the type, because the WebElement object applies to all Web objects.


Using ChildObject method to get all child object on home page and proint out their index and outertext properties.

set allHomePageChilcObject=browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").ChildObjects()
allHomePageChilcObjectCount=allHomePageChilcObject.count

For i=1 to allHomePageChilcObjectCount
 childObjectOuterText= browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebElement("index:="&i).GetROProperty("outertext")
 Print "index:"&cstr(i)&"      outertext:     "&childObjectOuterText
Next


Using childobject method to find the date object being displayed on the hompage.


[ 打印 ]
阅读 ()评论 (0)
评论
目前还没有任何评论
登录后才可评论.