Problem:
I have 50 test scripts stored in Quality Center (in different sub folder’s), It’s a time consuming process to open individual scripts from different folder and executing them back. Is there any way to open QTP script from different location?
OR
How to open QTP script from QC using .vbs file?
OR
How to execute scripts from QC?
Solution: VBS file can be used to open QTP scripts from quality center and executing them back. Refer the below code to open QTP, connect to QC and execute the selected scripts.
--------------------------------------------------------------------------------------------------------
Dim QTP_App ' Declare the Application object variable
Dim QTP_Test ' Declare a Test object variable
Dim QTP_Results ' Declare a Run Results Options object variable
Dim QC_Path ' Declare QC Path and assigned actual path
' Create the Application object
Set QTP_App = CreateObject("QuickTest.Application")
' Start QuickTest
QTP_App.Launch
' Make the QuickTest application visible
QTP_App.Visible = True
'Connect to Quality Center
QTP_App.TDConnection.Connect QC_Path, False
'Run a test
Call OpenScriptRunTest (ScriptName,TestSetName)
'Function to open QTPScript and run that script
Function OpenScriptRunTest (ScriptName,TestSetName)
QTP_App.Open QC_Path&ScriptName,True
QTP_App.Options.Run.ImageCaptureForTestResults = "OnError"
QTP_App.Options.Run.RunMode = "Fast"
QTP_App.Options.Run.ViewResults =True
Set QTP_Test = QTP_App.Test
QTP_Test.Settings.Run.IterationMode = "allIterations"
QTP_Test.Run.StartIteration = 1
QTP_Test.Run.EndIteration = 1
QTP_Test.Run.OnError = "NextStep"
Set QTP_Results = CreateObject("QuickTest.RunResultsOptions")
QTP_Results.TDRunName="Run_Sample"
QTP_Results.TDTestInstance=1
QTP_Results.TDTestSet=QC_Path&TestSetName
QTP_App.Test.Run qtRunResultsOptions
QTP_App.Close
End Function