Web Add-in Extensibility Developer Guide > JavaScript Function Reference > Test Object Operations > Test Object Method Function

Test Object Method Function      

Description

Simulates an action on a Web page.

Syntax

function <operation>(<parameters>)

Return Value

true on success, otherwise false.

Remarks

<Control>

    <Run>

        <Methods>

            <Method name="SetUsername"

                        type="javascript" function="PerformSetUsername"/>

        </Methods>

    </Run>

</Control>

Status Reporting

A test object method should report on the completion status of the operation. There are number of symbolic constants you can use to report execution status in your operations functions. They are:

micPass (0) - Causes the status of this step to be passed and sends the specified message to the run results. Use this code only if your method actually checks that the action succeeded at the application level. Normally, this code is used only by UFT.

micFail (1) - Causes the status of this step to be failed and sends the specified message to the run results. When this step runs, the test or component fails. Use this code to indicate that the method failed to run as expected.

micDone (2) - Sends a message to the run results without affecting the pass/fail status of the test or component. Use this code to indicate that the method ran to completion. This is the most common code to use in a test object function.

micWarning(3) - Sends a warning message to the run results, but does not cause the test or component to stop running, and does not affect the pass/fail status of the test or component.

For example:

_util.Report(micDone, "Set", toSafeArray(new Array(state));

Example

This example sets the text in a text field.

function SetUsername(text)

{

    // When clearing the text in the text area we get NULL or empty string.

    // Converting both to empty string.

    _elem.innerHTML = text != null? text: "";

    return true;

}