Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to call function lib at run time from an action
#1
Not Solved
Maybe silly, but i have developed an automation framework where in i
need to call a Demo.qfl (runtime) from an ACTION. If i use the
following funcLibraryFile() , it fails to call since QTP doesnt know
which lib to check this function since qfl is not loaded atall. I can
not use Absolute file path.

Call funcLibraryFile("Demo.qfl")

My Sub is and i am using executeFile
Code:
sub funcLibraryFile(libFile)

       Set fso=CreateObject("Scripting.FileSystemObject")
       strTestPath=Environment.Value("TestDir")

       strBinPath=fso.GetAbsolutePathName(strTestPath & "..\\..\\..\\..\
\lib")
       strFileName=fso.BuildPath(strBinPath,libFile)

       If fso.FileExists(strFileName) Then
               executeFile(strFileName)
       else
               errNum=err.number
       End If

       Set fso=Nothing
end sub

Any ideas?

thanks-anil
Reply
#2
Not Solved
Hi Anil,

First of all, I would like to know why you want to call a Function Library. As far as I know, Libraries are not meant to be called, rather it are meant to be attached to the test and the Functions inside the library are to be called.

So you can attach the Function Library(.qfl file) to your test prior to test run.You can anyway call any function inside the library from your script.

For attaching library files during run time you can try the following code:

Quote:Set qApp = CreateObject("QuickTest.Application")
qApp.Test.Settings.Resources.Libraries.Add(LibraryPath,Position)
Please let me know..
Reply
#3
Not Solved
Thanks for your response. I need it at runtime since when checked in
Clearcase, other folks in the project get 'Missing Resource' when they
access the Test/ACTION. Thus if it is at runtime, no missing resources. Also for the framework, there is a requirement not to add them through IDE but to call all components of framework at runtime. I have put msgbox and corrent path is shown from the ACTION (when not called from the function )

I will try your solution and respond again later. But if i make your code a function and call in ACTION, will i be able to?

thanks-anil
Reply
#4
Not Solved
Yes, you should be able to use these codes inside a function.
Reply
#5
Not Solved
Hi,

You can use the "ExecuteFile" method in order to load the library function dynamically while running the script.

Code:
ExecuteFile "..\..\..\LibraryFiles\MyLibrary.vbs" 'Enter your path here

Let me know if you need any more information.
Thanks,
SUpputuri
Reply
#6
Not Solved
SUpputuri/Prabhat , thanks for the response but how can i call this in isolation. I need Environment.Value("TestDir") to get the current path and then use BuildPath to build the path. Remember its a framework and if i need to put all this in a function ( in a vbs file) , how will i call this from ACTION since the lib is not loaded yet.
regards-anil
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Object not found during the 2nd iteration of an Action call in a For loop BGunay 0 973 04-23-2020, 07:08 PM
Last Post: BGunay
  QTP not recogonising object during run time Lavanya N 2 3,727 10-28-2015, 12:46 PM
Last Post: vinod123
  Writing to Run time data table Neetha 5 12,171 08-27-2015, 10:18 AM
Last Post: supputuri
  Calling a function in a Test Script from a function library anupam4j 3 6,123 06-26-2015, 12:31 AM
Last Post: babu123
  Not able to call the function kathirvelnagaraj 1 2,611 01-06-2015, 07:24 PM
Last Post: kathirvelnagaraj

Forum Jump:


Users browsing this thread: 1 Guest(s)