Stage 3: Teaching UFT One to Identify, Spy, and Learn the Book Control
To support a custom control, UFT One must be able to identify which test object class should represent a given control. Therefore, the most basic element of Web Add-in Extensibility is the Identification element, defined within each Control element in the toolkit configuration file. Each Control element defines a test object class. The Identification element specifies which controls should be represented by that test object class.
When UFT One needs to recognize a control in the application being tested, it checks the Identification element defined for each test object class. The first test object class whose Identification definition matches the control is used to represent the control.
As described in Planning Support for the Web Add-in Extensibility Book Sample Toolkit, any control whose tagName property is table and whose className property is Book is represented by a WebExtBook test object. This can be defined simply in the toolkit configuration file and does not require using JavaScript functions.
To define the identification rules for the WebExtBook test object class:
Replace the text in the WebExtSample.xml file with the following text:
<?xml version="1.0" encoding="UTF-8"?>
<Controls>
<Control TestObjectClass="WebExtBook">
<Identification>
<Browser name="*">
<Conditions type="IdentifyIfPropMatch" logic="and">
<Condition prop_name="tagName" expected_value="TABLE"/>
<Condition prop_name="className" expected_value="Book"/>
</Conditions>
</Browser>
</Identification>
</Control>
</Controls>
This adds an Identification element to the Control element that defines the WebExtBook test object class. The Identification element includes one Conditions element that contains two conditions, both of which must be met for the control to qualify as a WebExtBook. The Condition elements within the Conditions element specify one condition each. In each condition, the value of the specified HTML property of the control must match (case-insensitive compare) the specified expected value.
This tutorial uses the definition above to illustrate the use of more than one Condition element within a Conditions element. However, if you were working with an application that had many controls on a page, or a large DOM structure, this would be a better way to define the identification rules:
<Identification>
<Browser name="*">
<HTMLTags>
<Tag name="TABLE"/>
</HTMLTags>
<Conditions type="IdentifyIfPropMatch">
<Condition prop_name="className" expected_value="Book"/>
</Conditions>
</Browser>
</Identification>
This definition provides improved performance because it instructs UFT One to perform the identification process only on TABLE elements.
For more information on defining the Identification element for a test object class, see Teaching UFT One to Identify the Test Object Class to Use for a Custom Web Control and the Toolkit Configuration Schema Help.
To complete this stage, perform the procedures in Deploying and Testing the Toolkit Support Set (for Stage 3).