Friday, February 11, 2011

Execution of .vbs or .txt files in qtp

To execute the .vbs or .txt files in qtp, user has to associate those file in qtp

Associate library files in qtp

Concept behind this association of library file is that the script is written in separate library file like .vbs or .txt file and to run script you need to associate those files if you want to use them. After Association of the file, File will place in File -> settings -> resource.

There are two way to execute those files in qtp

1.       ExecuteFile key word
2.       Associate in Library

1.       ExecuteFile keyword:

ExecuteFile "File path" ( E.g: ExecuteFile “C:\test.vbs” )
In this concept, user has to call the function defined the .vbs file. Here library file will not be placed in File -> settings -> resource. But still user can access function defile in the file.
2.       Associate in Library:
Here, run time association of the file will be placed in File -> settings -> resource path in qtp.
Now user can access the function by calling it.

Example:

Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True
App.Test.Settings.Resources.Libraries.RemoveAll
App.Test.Settings.Resources.Libraries.Add "D:\test1.vbs”
App.Test.Settings.Resources.Libraries.Add "D:\test2.vbs"
Set App = Nothing

Note:    Associate file concept will help users to debug in file while run time however ExecuteFile will not be help in debugging.


No comments: