LoadFunctionLibrary Statement
Description
Loads the specified function library when this step runs. After the function library is loaded, the definitions in the library (functions, subroutines, classes) are available.
Note: This statement provides functionality similar to that provided by the ExecuteFile Statement, with the following differences:
LoadFunctionLibrary enables you to debug the functions in the function library during run-time.
For tests, the definitions in a function library loaded by LoadFunctionLibrary statement are available globally until the end of the run session, whereas the definitions in a file run by ExecuteFile statement are available only within the scope of the action that called the statement.
For components, in both cases the definitions are available in the scope of the component that called the statement.
Syntax
LoadFunctionLibrary(Path)
Argument | Type | Description |
---|---|---|
Path | String | The path (or paths) of the function library to load. You can specify one or more absolute file system paths, relative paths, or ALM paths for both tests and components. If you specify multiple paths, separate them using a comma delimiter. |
Return Value
Variant.
IMPORTANT
The function library is not listed in the following (except during the run session):
The Solution Explorer pane in UFT One.
The Errors pane in UFT One.
The Comments tab in the UFT One Tasks pane.
The Dependencies tab in the ALM Test Resources module.
This can affect test or component maintenance because the function library can potentially be modified or deleted without anyone realizing that it is called by this test or component. Conversely, when performing maintenance on a test or component, this function library can be overlooked because it is not clearly visible as a resource.
If a function in the function library has the same name as a function in an associated function library (defined in the Folders pane of the Options dialog box), the function in the dynamically loaded function library is used.
Similarly, if more than one function library is loaded dynamically, and these function libraries each contain a function with the same name, UFT One uses the function in the last loaded function library.
If a dynamically loaded function library defines and initializes a global variable or a class, the value remains in effect for the remainder of the run session or until a new value is defined, whichever comes first.
Run performance can be affected because the function library is loaded during the run session (and not when the test is opened).
At the end of a run session, all of the function libraries that were dynamically loaded are unloaded. You can view the steps that ran during the run session in the Run Results window.
The following example loads function libraries and runs functions.
Dim strCurrentLibPath
Const strFrenchLibPath = "[ALM\Resources] Resources\QTP Resources\French\"
Const strEnglishLibPath = "[ALM\Resources] Resources\QTP Resources\English\"
Const strDefaultLibPath = "[ALM\Resources] Resources\QTP Resources\Default\"
' Determine the function libraries to load during the run session
If Environment.Value("Language") = "French" then
strCurrentLibPath = strFrenchLibPath
else if Environment.Value("Language") = "English" then
strCurrentLibPath = strEnglishLibPath
Else
strCurrentLibPath = strDefaultLibPath
End if
' Load the relevant function libraries for the current environment's language
LoadFunctionLibrary strCurrentLibPath + "DialogCrashChecks.qfl", strCurrentLibPath + "DialogL18NChecks.qfl"
' Perform a set of window object checks using the PerformDialogCrashChecks function from the DialogCrashChecks.qfl function library loaded in the previous step
PerformDialogCrashChecks Window("MyApplication")
' Perform a set of window object checks using the PerformL18NDialogChecks function from the DialogL18NChecks.qfl function library loaded previously
PerformL18NDialogChecks Window("MyApplication")
See also:
- CallServiceTest Statement
- CreateObject64 Statement
- DescribeResult Statement
- ExecuteFile Statement
- ExitAction Statement
- ExitActionIteration Statement
- ExitComponent Statement
- ExitComponentIteration Statement
- ExitTest Statement
- ExitTestIteration Statement
- GetLastError Statement
- InvokeApplication Statement
- IsPartialRun Statement
- LoadAndRunAction Statement
- LoadFunctionLibrary Statement
- ManualStep Statement
- Print Statement
- RegisterUserFunc Statement
- RunAPITest Statement
- SetLastError Statement
- UnregisterUserFunc Statement
- Wait Statement