01-03-2012, 08:46 PM
Assuming that we have a test script say "Test" on desktop... please include the below code in a vb file namely Test.vbs
Now in order to execute QTP script from command line we have to execute the above created vbs file from command prompt which will in turn launch QTP, open the script, run it and will display the result in command prompt only. Open command prompt and write following code: And press enter
C:\Documents and Settings\Ravi_Gajul\Desktop>cscript Test.vbs
Note : C:\Documents and Settings\Ravi_Gajul\Desktop is the location of Test.vbs..update this accordingly
If the script passes the result is declared in command prompt as follows:
The Run Status is: Passed
Regards,
Ravi
Code:
Dim qtApp 'Declare the Application object variable
Dim qtTest 'Declare a Test object variable
Dim qtResultsOpt'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
qtApp.Open "C:\Documents and Settings\testingsvs_qa\Desktop\Test",True' Open the test in read-only mode
Set qtTest = qtApp.Test
qtTest.Run ' Run the test
WScript.StdOut.Write "The Run Status is:" & qtTest.LastRunResults.Status' Check the results of the 'test run
qtTest.Close' Close the test
Set qtTest = Nothing' Release the Test object
Set qtApp = Nothing' Release the Application object
Now in order to execute QTP script from command line we have to execute the above created vbs file from command prompt which will in turn launch QTP, open the script, run it and will display the result in command prompt only. Open command prompt and write following code: And press enter
C:\Documents and Settings\Ravi_Gajul\Desktop>cscript Test.vbs
Note : C:\Documents and Settings\Ravi_Gajul\Desktop is the location of Test.vbs..update this accordingly
If the script passes the result is declared in command prompt as follows:
The Run Status is: Passed
Regards,
Ravi