Get List of Values      

Description

Returns the current possible values for a method argument that has a dynamic list of possible values.

Syntax

function get_list_of_values( method, argIndex )

Argument

Type

Description

method
String
The name of the method.
argIndex
integer
The position in the test object method signature of the argument for which the list of values is required. The index is 1-based.

Return Value

An array of values, or null.

Remarks

Implement this function to return the possible values for each test object method argument that is defined to have a dynamic list of values (the Argument element's DynamicListOfValues attribute is set to true in the test object configuration XML file).

UFT calls this function to present the user with a list of possible values when the user is editing a test. The function handles the case where the list of possible values depends on the current state of the control. Because this function must assess the control to determine the valid values, the control must be visible in the application for the function to run.

If this function is not implemented, and the list of possible argument values cannot be determined otherwise, UFT does not present a list of values to the user.

The default function name is get_list_of_values. You can specify a different function name in the toolkit configuration file. For example:

<Control>

    <ListOfValues type="javascript" function="get_mylist_of_values"/>

</Control>

Example

This example provides a dynamic list of values for the first parameter of a test object method defined GoToAuthorPage(AuthorName, AuthorURL).

function get_list_of_values( method, argIndex )

{

    // When creating a step with the GoToAuthorPage test

    // object method, provide a list of the authors of this book.

    var arr = new Array();

    if (method == "GoToAuthorPage")

    {

        // Do not handle AuthorURL

        if( argIndex > 1 ) return toSafeArray(arr);

        // Retrieve all authors

        var AuthorsCount = 0;

        for( var i = 0 ; i < _elem.rows[1].cells[0].children.length ; ++i )

        {

            if( _elem.rows[1].cells[0].children[i].tagName == "A" )

            {

                arr[AuthorsCount]=

                    "\""+_elem.rows[1].cells[0].children[i].innerText+"\"";

                AuthorsCount++;

            }

        }

        return toSafeArray(arr);

    }

    return null;

}