How to Load Function Library at Runtime in UFT

In this article, we will learn different ways to load function library at runtime in UFT.I hope you might already know how to create a function library and associates with a Test in UFT. If you don’t know, you can refer to my post Create User-Defined Functions in UFT. If you are working on a large-scale automation project and dealing with a complex automation framework, you might feel the need to associate some of the function libraries at runtime in UFT.

So lets get started!

Load Function Library at runtime in UFT

Ways to Load Function Library in UFT

The following are the different methods to load function library at runtime in UFT.

  • ExecuteFile
  • LoadFunctionLibrary

Load Function Library at runtime in UFT Using ExecuteFile Method

ExecuteFile file statement runs all codes in the specified function library thus making all functions and subroutines in the file available for use.

Syntax
ExecuteFile  Function Library File Path
Example:

ExecuteFile “C:\UFT_WorkSpace\FunLib\TestFunctionLib.qfl”


Load Function Library at runtime in UFT Using LoadFunctionLibrary Method

UFT 11 onwards HPE introduced LoadFunctionLibrary method to load function library at runtime. It also runs all code in the specified function library thus making all functions and subroutines in the file available for use. However, there are few differences between both ExecuteFile and LoadFunctionLibrary methods.I will discuss that at later part of this tutorial.

Syntax:
LoadFunctionLibrary  <Function Library File Path>
Example:

LoadFunctionLibrary “C:\UFT_WorkSpace\FunLib\TestFunctionLib.qfl”

ExecuteFile VS LoadFunctionLibrary in UFT

After you run an ExecuteFile statement, you can call the functions in the loaded file only within the scope of the calling action. However, after you run a LoadFunctionLibrary statement, the functions in the file are available to your entire test, until the end of the run session.
You cannot debug a file that is called using an ExecuteFile statement.LoadFunctionLibrary enables you to debug the functions in the function library during run-time.

Make the Scope of Functions Global, Loaded through ExecuteFile

Now we know that using ExecuteFile directly in an Action only makes that particular function library visible within the Action. In order to make the scope of the function library global throughout the tests, load the library through a function in one of the global libraries and it will be available to all the test’s Actions. The defined variables in the library will also become global if the ExecuteFile statement is called in a global library.

Conclusion

In this article we learned how learned two diffrent ways for loading function library at runtime.Hope you have liked this post.Please don’t forget to share it and if you have any questions please do mention that in the comment box.

Recommended Posts

Leave a Reply