Identification Function per Class

Description

Identifies the root element of the control.

Syntax

function is<class name>()

Return Value

If the element is not part of a custom control of this class, return false.

If the element is part of a custom control of this class, return one of:

    • true — if the element is the root element of a control.
    • A reference to a different element, that will serve as the root element of the control.
    • false — if the function will return true or a reference to the root element when a different element is learned. In other words, do not implement the function to identify the root element of the same control more than once.
Remarks
  • For a control that is an aggregate of several elements, only one of those elements returns either true or a reference. The others return false.
  • For example, if a table contains a refresh button in one of the cells, and it is the presence of that refresh button that identifies the table as an object of the class, there are two ways to return this information to UFT. The first is when the table is learned, to check whether it contains the refresh button and to return true if it does. In this case, when the button is learned, it returns false.

    The second approach is for the table to return false. When the button is learned, it returns a reference to the containing table.

  • Define the name of the function in a Control\Identification element in the toolkit configuration file.
Limitations

An identification function cannot return a FRAME element. This restriction applies to IFRAME elements as well.

If the element being learned is in a frame, the identification function cannot return an element that is outside that frame. If frames are nested, the identification cannot return an element from a frame at a different nesting level than the element being learned.

Example

This example shows the identification function for a calendar contained with other controls in a DIV. The root element of the custom control is the DIV.

From the toolkit configuration file:

<Control TestObjectClass="MyToolkitCalendar">

    <Identification type="javascript"

        file_name="MyCalendar.js" function="isMyToolKitCalender">

    </Identification>

</Control>

From MyCalendar.js:

function isMyToolKitCalender()

{

 

    var _div = _elem.parentNode;

 

    if ( _div != null )

    {

        If ( _div.tagName.toUpperCase() == "DIV" &&

            _div.className &&

            _div.className.indexOf("myToolKit-Calendar")

            != -1)

            return _div;

    }

 

    return false;

}