QTP\UFT LoadFunctionLibrary

1) What is LoadFunctionLibrary?
2) What is ExecuteFile?

LoadFunctionLibrary in UFT

UFT has LoadFunctionLibrary option to Load library at run time.
Previously only ExecuteFile was the option in QTP not (QTP11).

Example 1:    Single file load

Step1: Create a MyUft function file (MyUft.vbs in C:\Test)

Sub MyUft()
   Msgbox "Today's Date: " & Now
End Sub

Step2: Now in UFT run the following code

LoadFunctionLibrary "C:\Test\MyUft.vbs"
'call function
MyUft

Example 2: Multiple library Load

Step1: Create a MyUft function file (MyUft1.vbs MyUft2.vbs in C:\Test)

Sub MyUft1()
   Msgbox "Today's Date: " & Now
End Sub
Sub MyUft2()
   Msgbox "Today's Date: " & Now
End Sub

Step2: Now in UFT run the following code
LoadFunctionLibrary "C:\Test\MyUft1.vbs","C:\Test\MyUft2.vbs"
'call functions
MyUft1
MyUft2

2 What is ExecuteFile?
How can you load External Library files in UFT?

1) We can use Executefile function to load library files.
Example:    Run time
Executefile "C:\MyUft.vbs"
x=4
y=7
res=addNumbers(x,y)
msgbox res

'Code in External Library file.
function addNumbers(a,b)
Dim c
c=a+b
addNumbers=c
End Function

(2) We can load external Library files manually.
Goto : Test > Settings > Choose Resources tab > select '+' button > browse and select the
library file > click Ok.

Comments

Post a Comment

Popular posts from this blog

UFT File Types and File Extensions

QTP/UFT Version History

Synchronization in UFT