How to execute qtp script from command prompt?

Showing Answers 1 - 4 of 4 Answers

Hokrani

  • Dec 27th, 2005
 

You need to create a vbs file... then create a batch file....that's it

Saravanan A

  • Jan 24th, 2006
 

Hi,

Any of you have a coding for a batch file that opens and runs an action of QTP?

Thanks,

Saravanan A

  Was this answer useful?  Yes

jayasheela1

  • Mar 23rd, 2006
 

[Files]
NumberOfFiles=2
File1=C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\mailobjectexample;1
File2=C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\batch2_test;1

this is just a sample hope this would help any dbts get back

vijay

  • Dec 27th, 2006
 

hi dear,

         ther's no big issue to run vbscript. i will tell a way to run ...go to  start>run  then write full path of file and file name with .vbs and click ok......it will run, if error is there in script it will through the error. niether it will run.

thanks and regards

vijay kunwar

  Was this answer useful?  Yes

satyendra Sen

  • Jul 9th, 2007
 

Hi Vijay,
I have created script for separate-2 test case and after that create batch file, and run the script, script executed successfully, but result saved separate test case result folder. I want to create single folder for test result after run batch file then result will save separate folder.
Please mail me


Regards
Satyendra

  Was this answer useful?  Yes

Vinaya

  • Aug 22nd, 2007
 

Hi,

Can some body answer this?

I have created script for separate-2 test case and after that create batch file, and run the script, script executed successfully, but result saved separate test case result folder. I want to create single folder for test result after run batch file then result will save separate folder.
Please mail me

  Was this answer useful?  Yes

desaiameet

  • Aug 24th, 2007
 

Hi Jayasheela,
Can you let me know the procedure for running the script from the command prompt.
I did try to save the code that you attached as .bat and tried to run it but no response.

Your help will be more useful to me.

Thanks
Ameet

  Was this answer useful?  Yes

Hi all,

i craete the Batch file that is open the QTP script but that's do not run the script, so any one give the solution how can i run our script thrugh batch file give the command

  Was this answer useful?  Yes

kiranpaul20

  • Jun 16th, 2010
 

It is very much possible to launch a QTP test from Command prompt and then run it.

The script to open QTP and then load the test into QTP and run the test is given in the "QUick Test Automation reference" file which is given in the Documnentation Folder.

The path is "C:Program FilesMercury InteractiveQuickTest ProfessionalhelpAutomationObjectModel.chm"

i have taken this script from this file and changed the path of my test to be loaded and saved the file as a .vbs and executed it from the command prompt.

The script is given below for quick reference

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 "E:Test ScriptsactiTIME FunctionCalls Script", True ' Open the test in read-only mode

' set run settings for the test

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 = "E:Test ScriptsactiTIME FunctionCalls ScriptRes1" ' Set the results location

qtTest.Run qtResultsOpt ' Run the test

MsgBox 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

For this you should have created a test with some actions in QTP and saved it then you need to specify the path of the test correctly at qtapp.Open

Save this file in a desired location with a .vbs extension.

Launch command prompt by going to run and type cmd and click enter.

The command prompt is visible. Since i store this .vbs file in E drive i have changed the directory in command prompt to E drive

C:>E: and press enter

E:> "This will be displayed" now enter the vbs file and click enter

E:>testrun.vbs and clicked enter

Now the QTP will automatically launch load the specified test and runs it and gives you a message box prompt saying passed after the test is completed.

Kiran Paul

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions