Micro Focus QTP (UFT) Forums
Getting run time error while executing the QTP script in command prompt. - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Getting run time error while executing the QTP script in command prompt. (/Thread-Getting-run-time-error-while-executing-the-QTP-script-in-command-prompt)



Getting run time error while executing the QTP script in command prompt. - vishruth143 - 07-15-2013

Hi All,

I'm getting the below error when I tried to run the QTP script via command prompt.

Error Message: cmd_QTP.vbs<13,1> Microsoft VBScript runtime error: Type mismatch: 'Run'

In command prompt i'm using the command

cscript //nologo cmd_QTP.vbs

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

qtApp.Open "C:\Users\Vi$hruth143\Desktop\QTP\Scripts\LogIn", True ' Open the test in read-only mode

' set run settings for the test
Set qtTest = qtApp.Test
[b]qtTest.Run qtResultsOpt ' Run the test[/b]

WScript.StdOut.Write "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

I doubt the error is on code line 13 which is higlighted in the above code.

Please help me to get this resolved.

Thanks
Vishruth


RE: Getting run time error while executing the QTP script in command prompt. - vinod123 - 07-15-2013

What you said was correct. I think i have solved the issue you are facing. Just check this code
first you have to create an object and if not able to create. check if your running Admin mode
Code:
Dim App
Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True
Dim QTP_Tests(2)
QTP_Tests(1) = "C:\Documents and Settings\thomas\Desktop\Tests\paypage hits"
QTP_Tests(2) = "C:\Documents and Settings\thomas\Desktop\Tests\digitsecure net docs"
'Creating the RunResultsOptions object. It is a collection of properties that indicate preferences for the run results. E.g. ResultsLocation property as used below which tells the path in which the run results will be stored.
Set res_obj = CreateObject("QuickTest.RunResultsOptions")
For i = 1 to UBound (QTP_Tests)
App.Open QTP_Tests(i), True
Set QTP_Test = App.Test
res_obj.ResultsLocation = QTP_Tests(i) & "\Res25" ' Set the results location
'Using the Run method. Run Method runs the open test or business component and creates results in the specified file or Quality Center path. A Boolean value - true or false can be set. Indicates whether the Test.Run statement waits until the end of the run before performing the next statement in the automation script. Default=True.
QTP_Test.Run res_obj, True
QTP_Test.Close
Next
App.Quit
Set res_obj = nothing
Set QTP_Test = nothing
Set App = nothing