Академический Документы
Профессиональный Документы
Культура Документы
Project Overview
Description
The Object Repository automation object model enables you to manipulate QuickTest shared object repositories
and their contents from outside of QuickTest. The automation object model enables you to use a scripting tool to
access QuickTest shared object repositories via automation.
Just as you use the QuickTest Professional automation object model to automate your QuickTest operations,
you can use the objects and methods of the Object Repository automation object model to write programs that
manipulate shared object repositories, instead of performing these operations manually using the Object
Repository Manager. For example, you can add, remove, and rename test objects; import from and export to
XML; retrieve and copy test objects; and so forth.
After you have retrieved a test object, you can manipulate it using the methods and properties available for that
test object class. For example, you can use the GetTOProperty or SetTOProperty methods to retrieve and
modify its properties. For more information on available test object methods and properties, refer to the
QuickTest Professional Object Model Reference.
Automation programs are especially useful for performing the same tasks multiple times or on multiple shared
object repositories. You can write your automation programs in any language and development environment that
supports automation. For example, you can use VBScript, JavaScript, Visual Basic, Visual C++, or Visual
Studio.NET. For general information about using automation with QuickTest, refer to the QuickTest Professional
User's Guide.
Note: You can use the Object Repository automation object model to manipulate shared object repositories
saved in the file system. If you want to manipulate a shared object repository stored in Quality Center, you must
download the shared object repository and save it to the file system, before using the Object Repository
automation object model to manipulate it.
Description
Enables you to manipulate object repository files (shared and local) from outside of QuickTest Professional.
Example
Manipulate Object Repositories Using the Object Repository Automation Objects and Methods
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
Methods
AddObject Adds the specified test object to the object repository under the specified
parent object.
Convert Converts the specified object repository file (version 8.2.1 or earlier) to
the current format.
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
CopyObject Creates a copy of the specified test object in the object repository.
ExportToXML Exports the specified object repository to the specified XML file.
GetAllObjects Retrieves all test objects under the specified parent test object.
GetAllObjectsByClass Retrieves all test objects of the specified class under the specified parent
test object.
GetChildren Retrieves all direct children of the specified parent test object.
GetChildrenByClass Retrieves all test objects of the specified class under the specified parent
test object.
GetLogicalName Retrieves the name of the specified test object. The name of the test
object as saved in the object repository.
GetObject Retrieves the test object according to the specified path.
GetObjectByParent Retrieves the test object according to the specified parent object and test
object name.
ImportFromXML Imports the specified XML file to the specified object repository.
RemoveObject Removes the specified test object from the object repository.
UpdateObject Updates the object repository with any changes made to the specified
test object.
Description
Adds the specified test object to the object repository under the specified parent object.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
object.AddObject (TestObject, Parent, [Name])
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Name Optional. A Variant value. The name you want to give the test object in the
object repository. If you do not specify a name, the name contained in the
test object is used.
Return Value
A Variant value. The name of the test object as saved in the object repository.
Remarks
You can either add a new test object that you have just created, or a copy of a test object that you retrieved
from a different object repository.
Note: If you created a new test object, you must initialize its properties before adding it to the object repository.
Description
Converts the specified object repository file (version 8.2.1 or earlier) to the current format.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
object.Convert (OldFile, NewFile)
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
OldFile Required. A String value. The full name and path of the object repository
you want to convert to the current format.
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
NewFile Required. A String value. The full name and path under which you want to
save the converted object repository. The file must be a new file (one that
does not already exist). The folder path must be an existing one.
Return Value
A Variant value. The full name of the converted object repository.
Remarks
You must convert object repository files from QuickTest Professional 8.2.1 or earlier to the current format before
you can use them in QuickTest Professional 9.0 or later.
Note: You do not need to use the Load method to load the object repository before converting it.
Description
Creates a copy of the specified test object in the object repository.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
object.CopyObject (TestObject)
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
An Object object. The copy of the test object.
Tip: You can use the returned test object as an argument value for other methods (for example,
AddObject, GetLogicalName, and UpdateObject.)
You can also use the test object's GetTOProperty and SetTOProperty methods to modify the returned test
object properties before updating them in the object repository (using UpdateObject.)
Remarks
To copy a test object from one object repository to another, you should first create a copy of the test object. This
ensures that the original test object in the original object repository is not influenced by any changes made to
the copied test object in the new object repository.
Description
Exports the specified object repository to the specified XML file.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
object.ExportToXML (SourceFile, TargetFile)
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
SourceFile Required. A String value. The full name and path of the object repository
you want to export to XML.
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
TargetFile Required. A String value. The full name and path of the XML file to which
you want to export the object repository. The XML file must be a new file
(one that does not already exist). The folder path must be an existing one.
Return Value
A Variant value. The full name of the new XML file.
Remarks
This method can only be used to export shared object repositories (*.tsr files).
The object repository you want to export must be in QuickTest version 9.0 or later format. If the object
repository is in an earlier format, you can use the Convert method to convert it before exporting it.
Description
Retrieves all test objects under the specified parent test object.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
object.GetAllObjects ([Parent])
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
A TOCollection object.
Remarks
You can use this method to enumerate test objects in an object repository and retrieve a collection of test
objects, even if you do not have any information about any of the test objects in the object repository.
Description
Retrieves all test objects of the specified class under the specified parent test object.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
object.GetAllObjectsByClass (Class, [Parent])
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
A TOCollection object.
Remarks
You can use this method to enumerate test objects in an object repository and retrieve a collection of test
objects, even if you do not have any information about any of the test objects in the object repository.
Description
Retrieves all direct children of the specified parent test object.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
object.GetChildren ([Parent])
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
A TOCollection object.
Remarks
You can use this method to enumerate test objects in an object repository and retrieve a collection of test
objects, even if you do not have any information about any of the test objects in the object repository.
Description
Retrieves all test objects of the specified class under the specified parent test object.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
object.GetChildrenByClass (Class, [Parent])
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
A TOCollection object.
Remarks
You can use this method to enumerate test objects in an object repository and retrieve a collection of test
objects, even if you do not have any information about any of the test objects in the object repository.
Description
Retrieves the name of the specified test object. The name of the test object as saved in the object repository.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
object.GetLogicalName (TestObject)
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
A Variant value.
Description
Retrieves the test object according to the specified path.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
object.GetObject (ObjectPath)
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
An Object object.
The specified test object's IDispatch pointer.
Tip: You can use the returned test object as an argument value for other methods (for example, AddObject,
CopyObject, GetLogicalName, and UpdateObject.)
You can also use the test object's GetTOProperty and SetTOProperty methods to modify the returned test
object properties before updating them in the object repository (using UpdateObject.)
Description
Retrieves the test object according to the specified parent object and test object name.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
object.GetObjectByParent (Parent, Object)
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Object Required. A String value. The test object, as it appears in the Expert View,
for example, WebEdit("password").
Return Value
An Object object. The specified test object's IDispatch pointer.
Tip: You can use the returned test object as an argument value for other methods (for example, AddObject,
CopyObject, GetLogicalName, and UpdateObject.)
You can also use the test object's GetTOProperty and SetTOProperty methods to modify the returned test
object properties before updating them in the object repository (using UpdateObject.)
Description
Imports the specified XML file to the specified object repository.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
object.ImportFromXML (SourceFile, TargetFile)
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
SourceFile Required. A String value. The full name and path of the XML file you want
to import into the new object repository.
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
TargetFile Required. A String value. The full name and path of the new object
repository to which you want to import the XML file. The object repository
file must be a new file (one that does not already exist). The folder path
must be an existing one.
Return Value
A Variant value. The full name of the new shared object repository.
Remarks
This method can only be used to import XML files into new shared object repositories (*.tsr files).
Description
Loads the specified object repository.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
object.Load FileName
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
None
Description
Removes the specified test object from the object repository.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
object.RemoveObject Parent, TestObject
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
None
Remarks
You can remove test objects from an object repository if they are no longer needed. Removing unnecessary test
objects helps to save disk space, simplifies maintenance, and improves object repository performance.
Description
Renames the specified test object in the object repository.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
object.RenameObject (TestObject, Name)
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Name Required. A String value. The new name you want to give to the test
object.
Return Value
A Variant value. The new name of the test object as saved in the object repository.
Remarks
You can rename a test object with a more descriptive name to make it easier to identify.
Description
Saves any changes you have made.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
object.Save
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
UNREGISTERED
None VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
Description
Updates the object repository with any changes made to the specified test object.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
object.UpdateObject TestObject
Argument Description
object An expression evaluating to an object of type ObjectRepositoryUtil.
Return Value
None
Remarks
You should call this method after any test object change (for example, rename, copy, and so forth.)
Description
A collection of test objects, returned by specific methods of the ObjectRepositoryUtil object.
Example
Manipulate Object Repositories Using the Object Repository Automation Objects and Methods
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
Methods
Item Returns the test object with the specified index from the test object
collection.
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
Copyright 1992-2006 Mercury Interactive Corporation
QuickTest Professional Object Repository Automation Reference
Count Method
Description
Returns the number of items in the test object collection.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
object.Count
Argument Description
object An expression evaluating to an object of type TOCollection.
Return Value
A Long value. The number of items in the collection.
Description
Returns the test object with the specified index from the test object collection.
Syntax (VB) < !-- old data end --> Parameter List < !-- old data end -->
Syntax
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
object.Item (Index)
Argument Description
object An expression evaluating to an object of type TOCollection.
Index Required. A Long value. The index of the test object you want to retrieve
from the collection.
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
Return Value
An Object object. The test object with the specified index.
Tip: You can use the returned test object as an argument value for other methods (for example, AddObject,
CopyObject, GetLogicalName, and UpdateObject.)
You can also use the test object's GetTOProperty and SetTOProperty methods to modify the returned test
object properties before updating them in the object repository (using UpdateObject.)
Function EnumerateAllChildProperties(Root)
'The following function recursively enumerates all the test objects directly under
'a specified parent object. For each test object, a message box opens containing the
'test object's name, properties, and property values.
????Dim TOCollection, TestObject, PropertiesCollection, Property , Msg
????Set TOCollection = RepositoryFrom.GetChildren(Root)
????For i = 0 To TOCollection.Count - 1
????????????Set TestObject = TOCollection.Item(i)
????????????Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine
????????????Set PropertiesCollection = TestObject.GetTOProperties()
????????????For n = 0 To PropertiesCollection.Count - 1
????????????????Set Property = PropertiesCollection.Item(n)
????????????????Msg = Msg & Property .Name & "-" & Property .Value & vbNewLine
????????????Next
????????????MsgBox Msg
EnumerateAllChildProperties TestObject
????Next
End Function
Function EnumerateAllObjectsProperties(Root)
'The following function enumerates all the test objects under a specified object.
'For each test object, a message box opens containing the test object's name,
'properties, and property values.
?Dim TOCollection, TestObject, PropertiesCollection, Property , Msg
????Set TOCollection = RepositoryFrom.GetAllObjects(Root)
????For i = 0 To TOCollection.Count - 1
????????Set TestObject = TOCollection.Item(i)
????????????????????Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine
????????????Set PropertiesCollection = TestObject.GetTOProperties()
????????????For n = 0 To PropertiesCollection.Count - 1
????????????????Set Property = PropertiesCollection.Item(n)
????????????????Msg = Property .Name & "-" & Property .Value & vbNewLine
????????????Next
????????MsgBox Msg
????Next
End Function
Function RenameAllImages(Root)
'The following function sets a new name for all image test objects under a specified object.
?Dim TOCollection, TestObject, PropertiesCollection, Property
????Set TOCollection = RepositoryTo.GetAllObjectsByClass("Image" )
????For i = 0 To TOCollection.Count - 1
????????????Set TestObject = TOCollection.Item(i)
????????????RepositoryTo.RenameObject (TestObject, "Image " & i)
????????????RepositoryTo.UpdateObject TestObject
????Next
End Function
Function RemoveAllLinks(Root)
'The following function recursively enumerates all the test objects under a specified object.
'It looks for all test objects of class Link and removes them from their parent objects.
????Dim TOCollection, TestObject, PropertiesCollection, Property
????Set TOCollection = RepositoryFrom.GetChildren(Root)
????Set TOCollection = RepositoryFrom.GetChildren(Root)
????For i = 0 To TOCollection.Count - 1
????????????Set TestObject = TOCollection.Item(i)
????????????TOClass = TestObject.GetTOProperty("micclass" )
?????????If TOClass = "Link" Then
????????????????RepositoryFrom.RemoveObject Root, TestObject
????????????End If
????????EnumerateAllChildProperties TestObject
????Next
End Function