08-03-2010, 01:30 AM
I created a test in QTProff and then tried to run the test from the command prompt through this script.
I fired the commands from C prompt:
1) cscript //nologo C:\Daily_Status_Checkout\Daily_Checkout.vbs
Where C:\Daily_Status_Checkout is my QTP script test location and Daily_Checkout.vbs is the script mentioned below.
Gave below mentioned error -
C:\Daily_Status_Checkout\Daily_Checkout.vbs(5, 1) Microsoft VBScript runtime error: ActiveX component can't create object: 'QuickTest.Application'
2) wscript C:\Daily_Status_Checkout\Daily_Checkout.vbs
Gave the attached error in a picture file.
C:\Daily_Status_Checkout\Daily_Checkout.vbs file:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code:
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible
' Set QuickTest run options
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False
qtApp.Open "C:\Daily_Status_Checkout", True ' Open the test in read-only mode
' set run settings for the test
Code:
Set qtTest = qtApp.Test
qtTest.Settings.Run.IterationMode = "rngIterations" ' Run only iterations 2 to 4
qtTest.Settings.Run.StartIteration = 2
qtTest.Settings.Run.EndIteration = 4
qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
qtResultsOpt.ResultsLocation = "C:\Daily_Status_Checkout\DSCRes1" ' Set the results location
qtTest.Run qtResultsOpt ' Run the test
WScript.StdOut.Write "Status is :" & qtTest.LastRunResults.Status ' Check the results of the test run
qtTest.Close ' Close the test
Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object
Please help me in running this automatically. I have tried adding some snippets as well to the script as shown below to kill any running session of QTProff.
Code:
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'QTPro.exe'"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
which also gave me the same error, asserting the fact that this was not the issue. So someone please guide me.