Web Add-in Extensibility Developer Guide > JavaScript Function Reference > General Test Object Functions > Get Base Element

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

    <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];

    }

}