Get Base Element      

Description

Returns an HTML element within the custom control, which represents the type of control that is supported by the base class. (The base class is the class that the test object class extends.)

Syntax

function <get base element>()

Return Value

A reference to the Web element that represents the type of control supported by the base class.

Remarks
  • Implementing a <get base element> function is mandatory if you want to inherit test object method implementation from the base class, and the root element of the custom control is not the type of control supported by that base class.
  • Define the name of the function in a func_to_get_base_elemControl\Settings\Variable element in the toolkit configuration file.
  • The <get base element> function returns a reference to the element in the custom control that is of the type supported by the base class. For example:
  • A class is defined in the Test Object Configuration

    <ClassInfo BaseClassInfoName="WebEdit"....

The control looks like this:

<FORM>

    <INPUT type="text" name="name" />

    <br />

    <INPUT type="radio" name="gender" value="male" /> Male

    <br />

    <INPUT type="radio" name="gender" value="female" /> Female

</FORM>

The root element is a FORM, which does not support the methods and properties of WebEdit. Therefore, for this class, a <get base element> function is required. The function returns a reference to the text field.

Example

Given this control:

<FORM>

    <INPUT type="text" name="name" />

    <br />

    <INPUT type="radio" name="gender" value="male" /> Male

    <br />

    <INPUT type="radio" name="gender" value="female" /> Female

</FORM>

And this class declaration:

<ClassInfo BaseClassInfoName="WebEdit"...

And this declaration in the toolkit configuration file:

<Control>

    <Settings>

    ...

    <Variable name="func_to_get_base_elem"

            value="get_base_element"/>

    </Settings>

    ...

</Control>

This example returns the text element, which is normally supported by a WebEdit test object.

function get_base_element()

{

    var children = _elem.childNodes;

    for (var 1=0; i < children.length; i++)

        if ( "text" == children[i].getAttribute("type"))

             return children[i];

    }

}