GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  QTP
Go To First  |  Previous Question  |  Next Question 
 QTP  |  Question 4 of 674    Print  
How to use automation object to load the library files in QTP. I tried to use this stmt" set App = createobject("Quicktest.Application")
App.Test.Settings.Resources.Libraries.Add ("F:QTPrepository.vbs"),1 ".could u pls help how to add it by script itself? what is executefile concept? is it workaround to my question?

  
Total Answers and Comments: 15 Last Update: March 20, 2008     Asked by: kittucivil 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Konka Ravi Krishna
 

This code will add the library files:

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable

Dim qtLibraries 'As QuickTest.TestLibraries ' Declare a test's libraries collection variable

Dim lngPosition

' Open QuickTest

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

qtApp.Launch ' Launch QuickTest

qtApp.Visible = True ' Set QuickTest to be visible

' Open a test and get its libraries collection

qtApp.Open "C:\Test1", False, False ' Open a test

Set qtLibraries = qtApp.Test.Settings.Resources.Libraries ' Get the libraries collection object

' Add Utilities.vbs if it's not in the collection

If qtLibraries.Find("C:\sai1.vbs") = -1 Then ' If the library cannot be found in the collection

qtLibraries.Add "C:\sai1.vbs", 1 ' Add the library to the collection

End If



Above answer was rated as good by the following members:
dasiga999
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
March 27, 2006 06:33:56   #1  
Konka Ravi Krishna        

RE: How to use automation object to load the library f...

This code will add the library files:

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable

Dim qtLibraries 'As QuickTest.TestLibraries ' Declare a test's libraries collection variable

Dim lngPosition

' Open QuickTest

Set qtApp CreateObject( QuickTest.Application ) ' Create the Application object

qtApp.Launch ' Launch QuickTest

qtApp.Visible True ' Set QuickTest to be visible

' Open a test and get its libraries collection

qtApp.Open C:\Test1 False False ' Open a test

Set qtLibraries qtApp.Test.Settings.Resources.Libraries ' Get the libraries collection object

' Add Utilities.vbs if it's not in the collection

If qtLibraries.Find( C:\sai1.vbs ) -1 Then ' If the library cannot be found in the collection

qtLibraries.Add C:\sai1.vbs 1 ' Add the library to the collection

End If


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
March 27, 2006 23:57:51   #2  
kittucivil Member Since: January 2006   Contribution: 2    

RE: How to use automation object to load the library f...

Hi Ravi Krishna

I am afraid the library file has not been added. There was an error while running This operation cannot be performed during a run session. Pls help me if you could run it successfully.


 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
April 05, 2006 00:05:47   #3  
Venkat        

RE: How to use automation object to load the library f...

Hi

when ever you want to add library files(.VBS) files to the script use th following function.

Executfile( Path of file )

the above fucntion load the VBS file to your script and you can use the fucntions in VBS file using

Call Functionname(arg list)

Venkat


 
Is this answer useful? Yes | No
December 21, 2006 11:53:04   #4  
Ram        

RE: How to use automation object to load the library f...

Hi

I have question

Can we add the library file while running the test

regards

Ram


 
Is this answer useful? Yes | No
January 03, 2007 07:49:20   #5  
lokesh        

RE: How to use automation object to load the library f...

Hi Ravi Krishna

Your answer is very good.But I've a doubt in it.U declared a variable as IngPosition but never used.Can u explain in detail what is that IngPosition

Thank u

Lokesh


 
Is this answer useful? Yes | No
January 31, 2007 01:22:43   #6  
Jitesh Sojitra        

RE: How to use automation object to load the library f...
I am also getting same error like

There was an error while running

This operation cannot be performed during a run session.

Pls help me if you could run it successfully.

 
Is this answer useful? Yes | No
February 23, 2007 23:14:23   #7  
Sirisha        

RE: How to use automation object to load the library f...
Easy Way to Load the Library Files is in Resource Settings Tab of Test Setting File box .When you load these it will take all the necessary functions from the library file while running the Script

Go to File ->Test Settings which Opens Test Settings Dialog box Click on Resource Tab then add the library files in the associated Librares by using the Browse Button.

 
Is this answer useful? Yes | No
March 13, 2007 03:50:36   #8  
manish        

RE: How to use automation object to load the library f...
Hi
This is Gre8 Script thank
I have changed it as per my requirement to add file to same Script

Dim qtApp
Dim qtLibraries

Set qtApp CreateObject("QuickTest.Application")
Set qtLibraries qtApp.Test.Settings.Resources.Libraries ' Get the libraries collection object

If qtLibraries.Find("C:sai1.vbs") -1 Then ' If the library cannot be found in the collection
ExecuteFile "C:sai1.vbs"
End If

Call test1()

Function In File Sai1.vbs
Function test1()
MsgBox "Hi Manish"
End Function




 
Is this answer useful? Yes | No
April 05, 2007 05:29:13   #9  
shruti        

RE: How to use automation object to load the library f...
Hi

I have recorded one script. Now i want to use the function Executefile.
Inorder to use this function is it necessary to load librabry files. If yes then can you please tell me how to make this library file.

 
Is this answer useful? Yes | No
April 17, 2007 07:25:45   #10  
debleena23 Member Since: April 2007   Contribution: 159    

RE: How to use automation object to load the library f...
Hi
The simplest way out is ......

Store the Library file along with the entire path in a variable.
EG: sPath "D:/Files/Functions.vbs"

Then just write ......

Executfile (sPath)

OR
Just write ...........
Executfile ("D:/Files/Functions.vbs")

Below this call which ever function you want to call from the library file
Call FunctName(argument list)


 
Is this answer useful? Yes | No
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape