QTP User Defined Functions

How to write and where we call user defined functions in QTP? Give an example.

Questions by sirin321

Showing Answers 1 - 4 of 4 Answers


  • Sep 7th, 2008

We can write user define functions in QTP Editor or in notepad also. when we write funtions in notepad we have to save file with .vbs extention. and close notepad then we can use that file in qtp resources. in resources we give notepad file path. than we can use funtion directly by functions name....

Using QuickTest, you can define and store your user-defined functions either in a function library (saved as a .qfl file, by default) or directly in an action within a test. A function library is a Visual Basic script containing VBscript functions, subroutines, modules, and so forth. You can also use QuickTest to modify and debug any existing function libraries (such as .vbs or .txt files). 

When you store a function in a function library and associate the function library with a test, the test can call the public functions in that function library.  Functions that are stored in an associated function library can be accessed from the Step Generator (for tests and function libraries) and the Operation column in the Keyword View, as well as being entered manually in the Expert View.

When you store a function in a test action, it can be called only from within that action—the function cannot be called from any other action or test. This is useful if you do not want the function to be available outside of a specific action.

You can also define private functions and store them in a function library. Private functions are functions that can be called only by other functions within the same function library. This is useful if you to reuse segments of code in your public functions.


  • Jun 1st, 2011

user defined functions are the functions defined/designed by the user for re-usability. to create a UDF first write the function in qtp(to avoid syntax mistakes) then copy , past the same in Note Pad and save the file with .vbs extension. Now to associate it in qtp, go to-file-settings-resources-click on + button and browse the .vbs file-click apply-click "ok".

  Was this answer useful?  Yes


  • Sep 8th, 2011

function name of the function
list of the statements
end function

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Answer Question

Click here to Login / Register your free account

Send   Reset


Related Answered Questions


Related Open Questions