QTP tutorials & interview questions


Search more on QTP here

Function Library Example 2

QTP Function Library - Example 2

Another example which uses both public and private functions in the function library.

1. Open a new function library. Go to File->New->Function library.

2. Open a new test. Go to File->New->Test.

3. Write the below two functions in the function library. One of the functions is private i.e. it can be accessed from within the function library itself and cannot be accessed from outside of this function library. One of the functions is public which we will access from the test.

Private Function my_name_tell(name2)
msgbox "Hello " & name2
End
Function

Public Function my_name(name1)
msgbox(name1)
my_name_tell(name1)
End Function

4. Save the function library.

5. Associate the function library with the test which is open.

In the expert view of the test type:

my_name("sachin")

7. When you run it, it will show two message boxes, one from the public function and second from the private function.


Also See:

QTP Function Library
QTP Function Library - Example 1
QTP Function Library - Example 3
QTP Function Library - Example 4
ExecuteFile