Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to call function lib at run time from an action
09-01-2010, 09:22 PM
Post: #1
How to call function lib at run time from an action

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

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
Find all posts by this user
Quote this message in a reply
09-02-2010, 12:48 PM (This post was last modified: 09-02-2010 12:50 PM by PrabhatN.)
Post: #2
RE: How to call function lib at run time from an action
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..

Happy Testing
Prabhat
Find all posts by this user
Quote this message in a reply
09-02-2010, 12:59 PM
Post: #3
RE: How to call function lib at run time from an action
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

(09-02-2010 12:48 PM)PrabhatN Wrote:  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..
Find all posts by this user
Quote this message in a reply
09-02-2010, 01:08 PM
Post: #4
RE: How to call function lib at run time from an action
Yes, you should be able to use these codes inside a function.

Happy Testing
Prabhat
Find all posts by this user
Quote this message in a reply
09-02-2010, 07:54 PM
Post: #5
RE: How to call function lib at run time from an action
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
Two benefits of Failure. First it makes us to Learn what does not work and second it gives us the opportunity to try a new approach.
Find all posts by this user
Quote this message in a reply
09-03-2010, 10:00 AM
Post: #6
RE: How to call function lib at run time from an action
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
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How to Set Ordinal Identifier at run time Amit Singh Chauhan 2 374 12-29-2011 11:43 AM
Last Post: Amit Singh Chauhan
  Alternate way to call resusable action by script hari1024 2 385 12-07-2011 09:32 PM
Last Post: hari1024
  Run Error on Function call mv8167 3 270 12-07-2011 12:46 AM
Last Post: mv8167
  Run Time Error Sathiya 1 360 10-29-2011 04:42 PM
Last Post: Arul
  How to call the reusable action in a test after updates sram24 1 474 10-27-2011 07:51 PM
Last Post: ravi.gajul

Forum Jump:


User(s) browsing this thread: 1 Guest(s)