Using Description Objects for Programmatic Descriptions
You can use the Description object to return a Properties collection object containing a set of Property objects. A Property object consists of a property name and value. You can then specify the returned Properties collection in place of an object name in a statement. (Each property object contains a property name and value pair.)
Note: By default, the value of all Property objects added to a Properties collection are treated as regular expressions. Therefore, if you want to enter a value that contains a special regular expression character (such as *, ?, +), use the \ (backslash) character to instruct QuickTest to treat the special characters as literal characters.
You can set the RegularExpression property to False to specify a value as a literal value for a specific Property object in the collection. For more information, see the Utility section of the HP QuickTest Professional Object Model Reference.
To create the Properties collection, you enter a Description.Create statement using the following syntax:
Set MyDescription = Description.Create()
Once you have created a Properties object (such as MyDescription in the example above), you can enter statements to add, edit, remove, and retrieve properties and values to or from the Properties object during the run session. This enables you to determine which, and how many properties to include in the object description in a dynamic way during the run session.
After you fill the Properties collection with a set of Property objects (properties and values), you can specify the Properties object in place of an object name in a test statement.
For example, instead of entering:
Window("Error").WinButton("text:=OK", "width:=50").Click
you can enter:
Set MyDescription = Description.Create()
MyDescription("text").Value = "OK"
MyDescription("width").Value = 50
Window("Error").WinButton(MyDescription).Click
Note: When using programmatic descriptions from a specific point within a test object hierarchy, you must continue to use programmatic descriptions from that point onward within the same statement. If you specify a test object by its object repository name after other objects in the hierarchy have been described using programmatic descriptions, QuickTest cannot identify the object.
For example, you can use Browser(Desc1).Page(Desc1).Link(desc3), since it uses programmatic descriptions throughout the entire test object hierarchy.
You can also use Browser("Index").Page(Desc1).Link(desc3), since it uses programmatic descriptions from a certain point in the description (starting from the Page object description).
However, you cannot use Browser(Desc1).Page(Desc1).Link("Example1"), since it uses programmatic descriptions for the Browser and Page objects but then attempts to use an object repository name for the Link test object (QuickTest tries to locate the Link object based on its name, but cannot locate it in the repository because the parent objects were specified using programmatic descriptions).
When working with Properties objects, you can use variable names for the properties or values to generate the object description based on properties and values you retrieve during a run session.
You can create several Properties objects in your test if you want to use programmatic descriptions for several objects.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16792402/viewspace-567243/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/16792402/viewspace-567243/