Wednesday, 16 September 2015

HOW TO RUN ALL TESTS IN A SPECIFIC FOLDER IN QUICKTEST PROFESSIONAL (QTP)?


Steps:

Declare the variables for qtpobj,fsoobj,dir,testcollection
Create an object using filesysytemobject
Use the getfolder to returs a folder
Assign the subfolders to testcollcetion variable
Create the object using reunresultsoptions
Setting the location for the run results
Execute the test. Instruct QuickTest Professional to wait for the test to finish executing
Close the qtp by  using close method
Relese the application object,runresults object

Ans:
Dim qtp_app
Dim file_sys
Dim Dir
Dim test_collection

Set qtp_app = CreateObject("QuickTest.Application")
qtp_app.Launch
qtp_app.Visible = True

' The file_systemObject object is used to access the file system on the server. This object can manipulate files, folders, and directory paths.
Set file_sys = CreateObject("Scripting.filesystemObject")

'GetFolder: Returns a Folder object for a specified path
Set Dir = file_sys.GetFolder( "C:\Program Files\HP\QuickTest Professional\tests1" )

Set test_collection = Dir.SubFolders

'RunResultsOptions:A collection of properties that indicate preferences for the run results.
Set qtResultsObj = CreateObject("QuickTest.RunResultsOptions")

For each t_folder in test_collection
qtp_app. Open t_folder.Path, True, False
'Setting the location for the run results
qtResultsObj.ResultsLocation = t_folder.Path & "\Res1" ' Set the results location
' Execute the test. Instruct QuickTest Professional to wait for the test to finish executing.
qtp_app.Test.Run qtResultsObj, True
qtp_app.Test.Close
Next
qtp_app.Quit
Set test_collection = Nothing
Set Dir = Nothing
Set file_sys = Nothing
Set qtp_app = Nothing

No comments:

Post a Comment