How to associate Function Libraries to a Test in QTP using Script?

Associating function libraries to a test in QTP is with respect to user defined functions which means either you or some one else are the owners of the functions and have rights to manage those functions. When it comes to writing scripts and running the test and that too in a frame work architecture every script is converted in to a function and relevant functions are called into the test script.


Functions in this context is the user defined and associating the function libraries to a test in QTP is by the two mentioned methods.

1. Using the feature of QTP
2. Using a Script.

Associating a Function Library using a Script

Step 1: Convert a script into a function, pass the necessary arguments, prepare the appropriate documentation for the function.

Step 2: Cut the function from the main script and open a note pad and paste the function in to the note pad and save it as a .vbs file in the appropriate folder.

Let us take the previous example of invoking/Login into the Flight Reservation application. We will create a library function called Login_FR and associate the function into QTP and it can be viewed by navigating to Resources and Associated Library Functions. When this is done you can just simply put the function call into the main script and run the test and you can see that QTP passes the username and password into the Flight Reservation application and you main script will have only one line of code and creating functions is useful for maintenance of the scripts.

Public Function LoginFR(byval username, byval password)

Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set username
Dialog("Login").WinEdit("Password:").Set password
Dialog("Login").WinButton("OK").Click

End Function

What you will do is cut this function from the main script and paste it in a note pad and save it as Login_FR.vbs

4 comments:

Kanikaram Kiranpaul said...

test comment

Kanikaram Kiranpaul said...

test comment to check footer

Software Testing Expert said...

how to create function for web application ?

Anonymous said...

thanks for sharing the more valuable information.
Indian Cyber Army credibility in Ethical hacking training & Cybercrime investigation training is acknowledged across nation as we offer hands on practical knowledge and full assistance with basic as well as advanced level ethical hacking & cybercrime investigation courses. The training is conducted by subject specialist corporate professionals with wide experience in managing real-time ethical hacking/ cyber security projects. Indian Cyber Army implements a blend of academic learning and practical sessions to give the candidate optimum exposure.Ethical hacking training ,
Ethical hacking course

Post a Comment

/* Tynt Insight tracker ----------------------------------------------- */