3

Say for eg., there are 20 vbs file in my frame work located at C:\LIBS\ I want to remove all already associated vbs file and add all 20 vbs present at above mentioned location.

I tried to get all files using below code

Set fso= CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\LIBS\")
Set fc = f.files
  For Each singlefile in fc
  msgbox singlefile.name
 Next

By this I was able to see all the vbs file. However I am not sure how can I use these file to associate it with my test.

Thanks in Advance.

Buddha
  • 4,339
  • 2
  • 27
  • 51
Irfan Khan
  • 31
  • 1
  • 4

4 Answers4

3

You can use LoadFunctionLibrary menthod to load any vbs file...

LoadFunctionLibrary "C:\LIBS\Library1.vbs"

You can place this to loop over all the files. You can also do this to load multiple libraries.

LoadFunctionLibrary "C:\LIBS\Library1.vbs", "C:\LIBS\Library2.vbs"

Using either of these methods, you have to place this LoadFunctionLibrary code to be run before any test code. Either associate this vbs file to your qtp script or put this in front of the test code in QTP script.

This approach is called dynamic loading of function libraries.

Buddha
  • 4,339
  • 2
  • 27
  • 51
  • True, but -- LoadFunctionLibrary´s ability to load more than one lib at once is undocumented, and i wonder, why – TheBlastOne Nov 05 '21 at 11:06
2

Another method you can use is

Set QtAp = CreateObject("QuickTest.Application")
QtAp.Open "C:\Sometest"
Set QtLib = QtAp.Test.Settings.Resources.Libraries
QtLib.RemoveAll
QtLib.Add "filepath",-1
QtAp.Test.Run

This script has to be run (in a driverscript) before executing the test. Hope this helps.

tentonipete
  • 5,080
  • 4
  • 25
  • 22
karthik27
  • 484
  • 1
  • 4
  • 12
0

Hi Hope This May Help u.. I just modified your code. Have a look, thank you

Set fso= CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\LIBS\")
Set fc = f.files
For Each singlefile in fc

    executeFile(singlefile.name) 

Next

Or

Set fso= CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\LIBS\")
Set fc = f.files

For Each singlefile in fc

    LoadFunctionLibrary (singlefile.name)

Next
-1
Dim App 'As Application

Set App = CreateObject("QuickTest.Application")

Set fso= CreateObject("Scripting.FileSystemObject")

Set f = fso.GetFolder("C:\Documents and Settings\Administrator\Desktop\Function Lib\")

Set fc = f.files

  For Each singlefile in fc

  'msgbox singlefile.name

App.Test.Settings.Resources.Libraries.Add(singlefile)

 Next

It will Associate your All Library File.

whoan
  • 8,143
  • 4
  • 39
  • 48