2008-04-15

How to run QTP test from command line?

Do you run your QTP tests suit manually?
What about running them on the schedule, for example nightly testing?

I will show the way how to do that - i.e. how to run QTP tests from command line.
Using that approach, you can execute your QTP tests on the schedule.

How to run QTP test from command line - QTP video tutorial


This is a script, which runs QTP tests (from the above QTP video tutorial):
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test 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:\Temp\simple_test", 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

Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object

Happy QTP scripting, dear readers! :)



Related articles:


Do you like this QTP visual tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)


40 comments:

  1. Hi Dmitry Motevich,
    Thanks a lot for ur videos. those are great for a starter like me. Ur blog site gives us lot of information n increases our knowledge in QTP.
    A request please load the videos in a format so that we can download easily.
    Please focus on Regular Expressions and Descriptive Programming a bit.
    Thanks & Regards
    Sheshadri

    ReplyDelete
  2. Thank you, Shashi, for your comment.

    I have several questions on your request:
    What video format do you ask?
    What file server should I use to store video files?
    Who will pay for this file server usage & big generated traffic?

    I'm working on video tutorial about Descriptive Programming. So, it will be ready in 1 week.

    As for Regular Expressions... This topic is explained on Internet widely. I do not plan to duplicate those articles.

    ReplyDelete
  3. hi

    The code for QTP regarding running the script from commandling was very excellent . Can you please concentrate regarding the driver script and Recovery scenarios in the driver script. And how to connect and execute QTP Scripts from QC. Please be a little bit elaborate on this issue.

    Any Help in this issue is highly appreciated.

    Regards,
    Vinesh.

    ReplyDelete
  4. Hi

    Thanks for presenting such good contents on your blog. The content posted by you is very excellent. In further postings from your side we expect you to post postings related to Recovery scenarios and developing the driver script and running the QTP script from Quality center and posting the results back to Quality Center.

    Regards,
    Satyam Reddy

    ReplyDelete
  5. Thanks very much it was very useful.

    ReplyDelete
  6. Dear Dmitry,

    It's wonderful video, but if you capture some more stuff such as how to capture checkpoint value, descriptive programming examples, parameterize value set up and merge two different scripts by function call that would be appreciated.

    Thanks!

    Nice job!! keep it up.

    Deven

    ReplyDelete
  7. 2Deven:
    Thank you.
    I will try to create QTP videos on others topics

    ReplyDelete
  8. Dmitry,
    Thanks for this video,
    This is very easy to understand.
    I have a request: I am focusing on automating using QTP on a VMware image, The test application is written using Visual C++ and "Windows XP" running on VMware Do you have any details, whether QTP identifies Windows XP image? Please let me know.

    ReplyDelete
  9. 2Sukanya:
    What do you mean with "QTP identifies Windows XP image"?
    What is "Windows XP image"?

    ReplyDelete
  10. Dmitry,
    "Windows XP Image" is is the VMware supported file, (files of format .vmx), If this is opened using VMware, it works as virtual computer with windows xp installed in it.
    Thanks,

    ReplyDelete
  11. 2sukanya:
    You didn't answer my another question.

    ReplyDelete
  12. Hey Dmitry...firstly I have to appreciate the time and effort you have taken to share your knowledge....you are doing a great job helping the community...keep it up !!!

    ReplyDelete
  13. hello,

    Thanks you for the video. I use the command line to run my QTP tests using vbscript, however i would like to know if it's possible to run QTP tests with another language like Python...

    Thanks. Your blog is very interesting.

    ReplyDelete
  14. to thomas_c (September 11),
    The QuickTest automation object model supplies a type library file
    named QTObjectModel.dll. This file is stored in 'QuickTest installation folder'\bin.

    So, you can access QTP Automation COM object from different programming language. I'm sure that Python provides such possibilities.

    ReplyDelete
  15. Hi Dmitry,

    This Video is preety good. Thanks for your effort. But if you will attach the Liberary Function files and Excel sheets to the script then do we need to write any mode code for the executing it?

    please let me know for the same.

    Best Regards,
    Chaitanya Rajkiran
    Chaitanya.jitm@gmail.com

    ReplyDelete
  16. to Raj (September 22),
    I didn't get you at all.

    What "Liberary Function files and Excel sheet" do you mean?
    What is "mode code"?

    ReplyDelete
  17. hi
    motevich
    before watching ur vedio
    i had one doubt how to use recovery scenario,now i understood how to do that,i watched ur vedio on recovery scenario its very good ,easy to understand,thanks a lot

    ReplyDelete
  18. Thank you so much for putting this video out there for everyone. It is a big help. I really appreciate the time and effort that you have put to make this so simple and easy to understand.

    ReplyDelete
  19. Thank you so much for putting this video out there for everyone. It is a big help. I really appreciate the time and effort that you have put to make this so simple and easy to understand.

    ReplyDelete
  20. @ sivakrishna & Rama,
    Thank you, my dear readers :)

    ReplyDelete
  21. Great! That helps me a lot! Thank you very much!

    ReplyDelete
  22. Your blog is very good...
    Please put more articles on Descriptive programming.
    Or if you have time send it to
    mail2lionel@yahoo.co.in

    ReplyDelete
  23. I recommend to subscribe to my blog and you will get all new published articles and videos

    ReplyDelete
  24. Thank You providing this information.
    /Sri

    ReplyDelete
  25. How do I set up a parameter in the command line and get the parameter in VBScript?

    I would like to set up some parameters to make the QTP Test run in different way.
    How do I set up the parameters in the command line and how do I retrieve the parameters in the VBScript?

    Many thanks for your replying.

    Bset Regards,
    Vincent

    ReplyDelete
  26. It was nice script

    would like something that runs the same way on a remote machine ..is it possible ?

    ReplyDelete
  27. Hi Dmitry,
    First of all...thank you for the time and effort you have put in...

    when I run your script I get the following error:
    Error: The server process could not be started because the configured identity is incorrect. Check the username and password.
    Code: 8000401A

    Any ideas how to solve it?

    ReplyDelete
  28. @Anonymous (February 18, 2009),
    Answered above.
    It's a pity that you didn't read above comments...

    ReplyDelete
  29. HiDimitry,
    the script closes the test but keeps the QTP application open. Could you please tell how you can close the application. cos my results are saved in a location and i can go visit them.

    ReplyDelete
  30. @Anonymous (March 5, 2009),
    qtApp.Quit

    ReplyDelete
  31. How To Run QTP Scripts at Scheduled Time?

    Set App = CreateObject("QuickTest.Application")
    App.Launch
    App.Visible = True
    App.WindowState = "Maximized" ' Maximize the QuickTest window
    App.ActivateView "ExpertView" ' Display the Expert View
    App.open "C:\Program Files\Mercury Interactive
    \QuickTest Professional\Tests\Test1", False
    'Opens the test in editable mode

    ReplyDelete
  32. Set App = CreateObject("QuickTest.Application")
    App.Launch
    App.Visible = True
    App.WindowState = "Maximized" ' Maximize the QuickTest window
    App.ActivateView "ExpertView" ' Display the Expert View
    App.open "C:\Program Files\Mercury Interactive
    \QuickTest Professional\Tests\Test1", False
    'Opens the test in editable mode

    ReplyDelete
  33. Hi,
    GREAT video, how do you schedule the task now?

    ReplyDelete
  34. Great Video!
    Now how do you schedule the task? Do you run the vbs file from the scheduled task on windows?

    ReplyDelete
  35. Excellent!! You truly are an expert with this tool. I will always use this blog for all my QTP related queries. Thank you very much.

    Regards,
    Suresh.

    ReplyDelete
  36. Hi Dmitry

    I am recording a dropdown box in my web application.I have to record all the options in the dropdown box and need to put a checkpoint on everylanding page.But the problem is when I try to record every optin individually the script gets too long.Is therea way that I can parameterize the option and the checkpoints.Please help me .Its urgent

    regards
    Sarika

    ReplyDelete
  37. Hi Dmitry

    I need to record a drop down box in my web application.I need to put a check point for every landing page.Is there a we can parameterize the values of the check point .Because when I try to record each option individually from the dropdown box the script gets too long.Please help me its really urgent

    regards
    Jyotsana

    ReplyDelete
  38. Hi Dimitry

    I was wondering how would I be able to open Tests that are not stored locally on my machine, e.g Test Director and Quality Center

    ReplyDelete