User-Defined Functions

Relevant for GUI tests and components

Note: The terms function, method, and operation are used interchangeably in this section.

In addition to the test objects, methods, and built-in functions supported by the UFT Test Object Model, you can define your own function libraries containing VBScript functions, subroutines, statement, and so on, and then call their functions from your test or use their functions as operations in your test or component.

A function library is a separate document that contains Visual Basic script. Any text file written in standard VBScript syntax can be used as a function library.

Your function libraries can contain:

  • Function definitions (function signature and code). You can call these functions from other functions, from actions in your test, or from your component. To call a function from a test or component, you must first associate the function library with the test or with the component's application area.

  • VBScript statements. These are statements that are not contained within function definitions (for example, RegisterUserFunc statements). UFT runs all of these statements when it loads the function library.

At the beginning of a run session, UFT loads all of the function libraries associated with your test or with your component's application area. If you need to dynamically load a function library during the test run, you can also use the LoadFunctionLibrary statement.

To see a demonstration of this functionality, go to the UFT Apps Marketplace page and select the Load Function library video.