Supporting Dynamic Lists of Values for Method Arguments

When a UFT user creates a test step with a test object method, UFT can display a set of predefined possible values available for the arguments of that method. For example, if an argument is a Boolean argument, UFT can display true and false as the possible values, or, for a month argument, UFT can display a list of names of all the months. However, sometimes, a limited set of possible values for an argument exists, but depends on the specific object on which the step is performed. For example:

Using extensibility, you can enable UFT to dynamically provide a list of values for arguments of test object methods. UFT provides this list only in the Editor, when the statement completion feature is used.

To support a dynamic list of values:

  1. In the test object configuration file, set the DynamicListOfValues attribute of the Argument element to true.

  2. In the toolkit configuration file, you can specify the file name and function name of the JavaScript function that UFT must call to retrieve the list of values. By default, UFT requests the list of values by calling the get_list_of_values JavaScript function from the default implementation file that you specify for the test object class in the default_imp_file variable in the Control\Settings element. For more information, see the Toolkit Configuration Schema Help.

    UFT calls the JavaScript function for every argument whose DynamicListOfValues attribute is set to true in the test object configuration file. The parameters provided to this function indicate the test object method and argument for which the values are being requested.

  3. Write a JavaScript function that accepts the names of the test object method and argument and returns a list of values relevant for the specified argument on the current element. Return the string values concatenated to one string, each value enclosed in quotation marks.

    Note: The dynamic list of values is retrieved from the control in the application being tested. Therefore, to display the dynamic list of values, the relevant control must be visible in the application when the test is edited.

For example, in the toolkit support set for the WebExtSample environment, located in <Web Add-in Extensibility SDK installation folder>\samples\WebExtSample folder, a dynamic list of values is supported for the AuthorName argument in the GoToAuthorPage test object method of the test object class WebExtBook.