Here is the sample code to connect QC and execute scripts stored in QC using QTP.
- 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 QTP 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
- '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
- 'Run a test
- Call OpenScriptRunTest (ScriptName,TestSetName)
Comments
Post a Comment