This tutorial describes how you could use Functions in QTP
Please be patient . Video will load in some time. If you still face issue viewing video click here
Video Transcript with Key Takeaways Highlighted
If you have segments of code that you need to use several times in your tests, you may want to create a user-defined function. By using user-defined functions, your tests are shorter, and easier to design, read, and maintain
Your own function libraries, can contain VBScript functions, subroutines, modules etc.
You need to follow 3 simple steps to use a function from a library in your test
To create a new function library in QTP
Select File > New > Function Library. It opens as a new tab in QTP
Lets a create a very simple function which shows Message Box.So whenever this function is called a message box must be displayed
You can have mutliple functions defined in the same file.Let's save the function
A function has an extension .qfl
Next Step Associate the library with your test
Click File > Settings > Resources > Associate Function Library.Click Add. Select The Function Library File.Click Okay
Last step to use the function
In your test simply call the function. When you run the test as expected Message Box is displayed
Using COM , DCOM objects you can create very advanced Functions
Infact, many of the features provided by QTP can be coded using VBScript
We have seen automation engineers who make it more of a VB project rather than automation project
Our recommendation is to focus on 100% automation rather than flaunting your VB skills