Friday

QTP- Ordinal identifier

Mercury QuickTest Professional User's Guide > Working with Advanced Testing Features > Configuring Object Identification > Understanding the Object Identification Dialog Box > Selecting an Ordinal Identifier

--------------------------------------------------------------------------------

Selecting an Ordinal Identifier
In addition to learning the mandatory and assistive properties specified in the Object Identification dialog box (Tools > Object Identification), QuickTest can also learn a backup ordinal identifier for each test object. The ordinal identifier assigns the object a numerical value that indicates its order relative to other objects with an otherwise identical description (objects that have the same values for all properties specified in the mandatory and assistive property lists). This ordered value enables QuickTest to create a unique description when the mandatory and assistive properties are not sufficient to do so.

Because the assigned ordinal property value is a relative value and is accurate only in relation to the other objects displayed when QuickTest learns an object, changes in the layout or composition of your application page or screen could cause this value to change, even though the object itself has not changed in any way. For this reason, QuickTest learns a value for this backup ordinal identifier only when it cannot create a unique description using all available mandatory and assistive properties.

In addition, even if QuickTest learns an ordinal identifier, it will use it during the run session only if the learned description and the Smart Identification mechanism are not sufficient to identify the object in your application. If QuickTest can use other test object properties to identify the object during a run session, the ordinal identifier is ignored.

QuickTest can use the following types of ordinal identifiers to identify an object:

Index—Indicates the order in which the object appears in the application code relative to other objects with an otherwise identical description. For more information, see Identifying an Object Using the Index Property.
Location—Indicates the order in which the object appears within the parent window, frame, or dialog box relative to other objects with an otherwise identical description. For more information, see Identifying an Object Using the Location Property.
CreationTime (Browser object only)—Indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description. For more information, see Identifying an Object Using the CreationTime Property.
By default, an ordinal identifier type exists for each test object class. To modify the default ordinal identifier, you can select the desired type from the Ordinal identifier box.





Tip: While recording, if QuickTest successfully creates a unique test object description using the mandatory and assistive properties, it does not learn an ordinal identifier value. You can add an ordinal identifier to an object's test object properties at a later time using the Add/Remove option from the Object Properties or Object Repository dialog box. For more information, see Working with Test Objects.

Identifying an Object Using the Index Property
While learning an object, QuickTest can assign a value to the test object's Index property to uniquely identify the object. The value is based on the order in which the object appears within the source code. The first occurrence is 0.

Index property values are object-specific. Therefore, if you use Index:=3 to describe a WebEdit test object, QuickTest searches for the fourth WebEdit object in the page. However, if you use Index:=3 to describe a WebElement object, QuickTest searches for the fourth Web object on the page—regardless of the type—because the WebElement object applies to all Web objects.

For example, suppose a page contains the following objects:

an image with the name Apple
an image with the name UserName
a WebEdit object with the name UserName
an image with the name Password
a WebEdit object with the name Password
The following statement refers to the third item in the list, as this is the first WebEdit object on the page with the name UserName:

WebEdit("Name:=UserName", "Index:=0")

In contrast, the following statement refers to the second item in the list, as that is the first object of any type (WebElement) with the name UserName:

WebElement("Name:=UserName", "Index:=0")

Identifying an Object Using the Location Property
While learning an object, QuickTest can assign a value to the test object's Location property to uniquely identify the object. The value is based on the order in which the object appears within the window, frame, or dialog box, in relation to other objects with identical properties. The first occurrence of the object is 0. Values are assigned in columns from top to bottom, and left to right.

In the following example, the radio buttons in the dialog box are numbered according to their location property.





Location property values are object-specific. Therefore, if you use Location:=3 to describe a WinButton test object, QuickTest searches from top to bottom, and left to right for the fourth WinButton object in the page. However, if you use Location:=3 to describe a WinObject object, QuickTest searches from top to bottom, and left to right for the fourth standard object on the page—regardless of the type—because the WinObject object applies to all standard objects.

For example, suppose a dialog box contains the following objects:

a button object with the name OK
a button object with the name Add/Remove
a check box object with the name Add/Remove
a button object with the name Help
a check box object with the name Check spelling
The following statement refers to the third item in the list, as this is the first check box object on the page with the name Add/Remove.

WinCheckBox("Name:=Add/Remove", "Location:=0")

In contrast, the following statement, refers to the second item in the list, as that is the first object of any type (WinObject) with the name Add/Remove.

WinObject("Name:=Add/Remove", "Location:=0")

Identifying an Object Using the CreationTime Property
While learning a browser object, if QuickTest is unable to uniquely identify the object according to its test object description, it assigns a value to the CreationTime test object property. This value indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description. The first browser that opens receives the value CreationTime = 0.

During the run session, if QuickTest is unable to identify a browser object based solely on its test object description, it examines the order in which the browsers were opened, and then uses the CreationTime property to identify the correct one.

For example, if you record a test or component on three otherwise identical browsers that are opened at 9:01 pm, 9:03 pm, and 9:05 pm, QuickTest assigns the CreationTime values, as follows: CreationTime = 0 to the 9:01 am browser, CreationTime = 1 to the 9:03 am browser, and CreationTime = 2 to the 9:06 am browser.

At 10:30 pm, when you run your test or component, suppose the browsers are opened at 10:31 pm, 10:33 pm, and 10:34 pm. QuickTest identifies the browsers, as follows: the 10:31 pm browser is identified with the browser test object with CreationTime = 0, 10:33 pm browser is identified with the test object with CreationTime = 1, 10:34 pm browser is identified with the test object with CreationTime = 2.

If there are several open browsers, the one with the lowest CreationTime is the first one that was opened and the one with the highest CreationTime is the last one that was opened. For example, if there are three or more browsers open, the one with CreationTime = 2 is the third browser that was opened. If seven browsers are opened during a recording session, the browser with CreationTime = 6 is the last browser opened.

If a step was recorded on a browser with a specific CreationTime value, but during a run session there is no open browser with that CreationTime value, the step will run on the browser that has the highest CreationTime value. For example, if a step was recorded on a browser with CreationTime = 6, but during the run session there are only two open browsers, with CreationTime = 0 and CreationTime = 1, then the step runs on the last browser opened, which in this example is the browser with CreationTime=1.

Note: It is possible that at a particular time during a session, the available CreationTime values may not be sequential. For example, if you open six browsers during a record or run session, and then during that session, you close the second and fourth browsers (CreationTime values 1 and 3), then at the end of the session, the open browsers will be those with CreationTime values 0, 2, 4, and 5).

No comments:

Post a Comment