Requesting a VBScript file for Executing a series of UFT tests
Tags:
Category:
Question ID: 107766
2
0

My client does not have ALM ,so currently we are having manually kick off each UFT test. Does anyone have a VBScript file they would be willing to share that would allow me to use UFT itself to handle the test executions?

Marked as spam
Posted by (Questions: 10, Answers: 5)
Asked on July 25, 2017 7:45 pm
179 views
Answers (5)
3
Private answer

HPE has a KM document ([KM182570][1]) that shows how to do this. If you have an HPE Passport login you can see it at that link. If not, I will paste the example code below.

Example 1:

Dim App
' Launch QuickTest Professional and make it visible.
Set App = CreateObject(''QuickTest.Application'')
App.Launch
App.Visible = True
' Load an .xml file with the user-defined parameters.
App.Test.Environment.LoadFromFile ''C:Test_Paramsenvironment_file1.xml''
' Declare an array with the paths and names of the tests.
dim testArray(2)
testArray(0) = ''C:Program FilesMercury InteractiveQuickTest ProfessionalTestsmytest''
testArray(1) = ''C:Program FilesMercury InteractiveQuickTest ProfessionalTestsmytest2''
testArray(2) = ''C:Program FilesMercury InteractiveQuickTest ProfessionalTestsmytest3''
Set qtResultsObj = CreateObject(''QuickTest.RunResultsOptions'')
' Loop through all the tests in the testArray.
for i = 0 to UBound (testArray)
' Open the test in QuickTest Professional.
App.Open testArray(i), True
' Get the test object.
Set qtTest = App.Test
' Set the test results options. Here the location for the test results will be set.
qtResultsObj.ResultsLocation = testArray(i) & ''Res1'' ' Set the results location
'Execute the test. Instruct QuickTest Professional to wait for the test to finish executing.
' This statement specifies a test results location.
qtTest.Run qtResultsObj, True
' Run the script using the default test results options.
' qtTest.Run
' Close the test.
qtTest.Close 'Close the test
next
' Close QuickTest Professional.
App.Quit
' Release the created objects.
set qtResultsObj = nothing
set qtTest = nothing
set App = nothing

If you need to modify the test set, you will simply need to modify the array containing the full path and test name. You can also add the statements to load and execute tests directly into the file removing the need for the array and looping statements. This will require more modifications when changes to the test set are needed.

Example 2:

Dim qtApp
Dim filesys
Dim maindir
Dim testCol
Dim checkfolder
Set qtApp = CreateObject(''QuickTest.Application'')
qtApp.Launch
qtApp.Visible = True
' Get the collection of test scripts
Set filesys = CreateObject(''Scripting.FileSystemObject'')
Set maindir = filesys.GetFolder( ''C:Program FilesMercury InteractiveQuickTest ProfessionalTes
tsTesting'' )
Set testCol = maindir.SubFolders
Set qtResultsObj = CreateObject(''QuickTest.RunResultsOptions'')
' Loop through each test in the collection
For each fl in testCol
' Verify the folder is a QTP test
checkfolder = fl.Path & ''Action0''
If (filesys.FolderExists(checkfolder)) Then ' The folder is a QTP test folder
' Open the test.
qtApp. Open fl.Path, True, False
' Set the test results options. Here the location for the test results will be set.
qtResultsObj.ResultsLocation = fl.Path & ''Res1'' ' Set the results location
' Execute the test. Instruct QuickTest Professional to wait for the test to finish executin
g.
' This statement specifies a test results location.
qtApp.Test.Run qtResultsObj, True
' Close the test.
qtApp.Test.Close End If
Next
' Close QuickTest Professional.
qtApp.Quit
' Release the File System Objects
Set testCol = Nothing
Set maindir = Nothing
Set filesys = Nothing
' Release the QuickTest Professional application object
Set qtApp = Nothing

Once you have the VBS file ready, you can execute it by double clicking it or running it from the command line.

I hope that helps.

[1]: https://softwaresupport.hpe.com/group/softwaresupport/search-result/-/facetsearch/document/KM182570

Marked as spam
Posted by (Questions: 16, Answers: 807)
Answered on July 25, 2017 8:13 pm
0
That's fantastic! Thank you! I did an internet search but this didn't come up. Much appreciated!
( at July 25, 2017 8:23 pm)
1
Private answer

Recommend looking into using UFT ''Test Batch Runner'' which is installed on the machine with UFT. See [Create and run a test batch][1] in the online help for UFT 14.

[1]: http://uft-help.saas.hpe.com/en/14.00/UFT_Help/Content/User_Guide/how2_run_batch.htm

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on July 25, 2017 10:02 pm
0
@bubblehead712 do you know if this works with UFT 12.54?
( at August 7, 2017 12:37 pm)
0
@bubblehead712 nevermind - it does! What a time saver - THANK YOU!!!
( at August 7, 2017 1:13 pm)
0
Private answer

That's fantastic! Thank you! I did an internet search but this didn't come up. Much appreciated!

Marked as spam
Posted by (Questions: 10, Answers: 5)
Answered on July 25, 2017 8:23 pm
0
Private answer

@bubblehead712 do you know if this works with UFT 12.54?

Marked as spam
Posted by (Questions: 10, Answers: 5)
Answered on August 7, 2017 12:37 pm
0
Private answer

@bubblehead712 nevermind - it does! What a time saver - THANK YOU!!!

Marked as spam
Posted by (Questions: 10, Answers: 5)
Answered on August 7, 2017 1:13 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top