I used the below code to open QTP through VBscript?But i can
unable to Invoke QTP...PLZ help me with the correct code to
invoke QTP through VBS with description of the code aswell.

Dim qtApp 'As QuickTest.Application
'Declare the Application object variable
Dim qtTest 'As QuickTest.Test
'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 = False 'Make the QuickTest application
visible
qtApp.Open "C:\form", True
'Open the test in read-only mode
'set run settings for the test
Set qtTest = qtApp.Test
qtTest.Run 'Run the test
'WScript.StdOut.Write "Status is: " &
qtTest.LastRunResults.Status
'Check the results of the test run
qtTest.Close 'Close the test
qtApp.quit 'Close QuickTest Pro
Set qtResultsOpt = Nothing 'Release the Run Results Options
object
Set qtTest = Nothing 'Release the Test object
Set qtApp = Nothing 'Release the Application object




I used the below code to open QTP through VBscript?But i can unable to Invoke QTP...PLZ help me wi..

Answer / Saurav Kumar Rohilla

The provided code is almost correct, but there are a few modifications required for successful execution. Here's the corrected version:

```vbscript
Dim qtApp As Object
Set qtApp = CreateObject("QuickTest.Application") 'Declare and create the Application object
qtApp.Visible = False 'Make the QuickTest application invisible
qtApp.Launch "Start QuickTest" 'Start QuickTest by passing Start QuickTest as an argument to launch the QTP
qtApp.Open "C:form", True 'Open the test in read-only mode, replace C:form with your actual QTP script path
qtApp.Run 'Run the test
Dim qtResults As Object
Set qtResults = qtApp.Test.LastRunResults 'Get the Last Run Results of the Test object
WScript.StdOut.Write "Status is: " & qtResults.Status 'Check the results of the test run
qtApp.Close 'Close the test
qtApp.quit 'Close QuickTest Pro
Set qtResults = Nothing 'Release the Run Results object
Set qtApp = Nothing 'Release the Application object
```

The main issue with your code was incorrect declaration of the application, test, and run results objects. Instead of using 'QuickTest.Application', use 'Object'. Additionally, change the line where you declare the Test object to set it as a property of the Application object: Set qtResults = qtApp.Test.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More QTP Interview Questions

what are the functions availabla in QTP? what are the data types in QTP?

2 Answers   Spry Technologies,


Hi all, I am using windows vista, I am in the process of learning QTP. When ever I try to work with insert mode in flight application , i am getting the error of 'Operation must use an update table query, fractional truncation(null) error. Can anyone help me regarding this?

1 Answers  


Deal All, Recently i face one interview question in one company. str="test12@#3456" In This i want to print like special character and numeric ,word in one script please tell me how to write the code for this Thanks Balaji

1 Answers  


I am executing a batchfile.In one script on one Button i have inserted a checkpoint.It is in a loop,my checkpoint is going to fail sometimes.That failed results only I have to log in a file.How it's possible...pls give the solution for this?

6 Answers   Wipro,


What is the use of an object spy tool in qtp?

1 Answers  


Write the Test Cases for ATM(Any Time Money)

3 Answers   SpaceLabs,


What is data driver in qtp?

1 Answers  


In an interview, what r the general questions asked in QTP? pls give me anwser to this question?

1 Answers  


Hi guys can any plz help me how to send fax in sample Flight Appication

1 Answers  


If an application name is changing frequently i.e while recording it has name “Window1” and then while running its “Windows2” in this case how does QTP handle?

7 Answers   Covansys,


Discuss QTP Environment.

1 Answers  


When you open QTP, how many sheets you can see?

1 Answers   Wells Fargo,


Categories