Load/associate a function library (vbs, txt, qfl) for use with a script

  • Via User-Interface. Note: this approach loads the associated function library’s contentsbefore loading/reading the Test’s actions
    • Via Test’s Settings (all versions):

1. Navigate to QTP’s File menu and select "Settings" option

2. Access the "Resources" tab

3. Under the "Libraries" section’s listing "Associated Function libraries", click the "+" sign (plus)

4. Type the path of the desired file (or browse to find it)

5. Click "Apply" and/or "Ok"

6. Save test

  • Via "Resources" panel (QTP 9.5 – QTP 11):

1. Access the panel by enabling it under QTP’s View menu

2. Once displayed, right click on top option "Associated Function Libraries" and select given option

3. Select the desired file, and click on "Open"

4. Save the test

  • Via "Solution Explorer" pane (UFT 11.5 and above):

1. Display the Solution Explorer pane (View > Solution Explorer)

2. Right-click the GUI test node and select "Add > Associate Function Library", or right-click the "Function Libraries" node within the relevant test’s node in the tree and select "Associate Function Library".

3. Select the desired file, and click on "Open"

4. Save the test

  • Programmatically (run-time/running-testscript). Depending on the version of QTP (or UFT), there are 2 coding statements:

    Note: This approach loads and makes available the contents of function library, after running below statements

    (Important) Library files should not have syntax errors(by opening library file with QTP, then using Ctrl+F7 or "Check Syntax" option under QTP > Tools) before running scripts where files get loaded dynamically. These programmatic statements don’t validate the possibility of syntax errors, therefore possibly causing functions not being loaded/found as well given unexpected errors.


  • ExecuteFile. It loads the contents of library files, BUT it doesn’t associate them to test. Note: this option doesn’t allow debugging visually line by line a running code, because the execution marker (yellow arrow on the left displayed on left margin of code when running a script) points can’t point to correct line, which can end up pointing to blank/commented or even wrong lines when reporting an error of such files.

    ExecuteFile "C:\MyLibraries\MyLibrary.qfl"

  • LoadFunctionLibrary. Associates and load the contents of a library to running memory of the script. Offered starting QTP version 11, to dynamically associate function libraries (vbs, qfl, txt) to a currenlty running test. Deprecates "ExecuteFile" since it allows debugging step-by-step execution, displaying the correct line running (and displaying line number and contents when erroring out)

    LoadFunctionLibrary "C:\MyLibraries\MyLibrary.qfl"

Via Automation Object Model (AOM – QTP API). The AOM feature offers Libraries property (a collection object of type "TestLibraries") as part of the Test object properties. For users to implement its usage, it is necessary to create a VBScript file with required statements and execute (by double clicking file)Note: Any AOM implementation is only supported outside QTP (not executed by QTP).Set QTP = CreateObject("QuickTest.Application") QTP.Launch QTP.Visible = True QTP.Open "C:\Tests\Test1", False, False QTP.Test.Settings.Resources.Libraries If QTP.Test.Settings.Resources.Libraries.Find("C:\Utilities.vbs") = -1 Then QTP.Test.Settings.Resources.Libraries.Add "C:\Utilities.vbs", 1 End If QTP.Test.Save ‘ Save the test QTP.Quit ‘ Quit QuickTest Set QTP = Nothing


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s