Thursday, September 17

VBScript - 1 . Launching QTP

As many are aware that QTP tool has good compatibility with VB script. VB Script like any scripting langaugae has quite good advantages and when combined with automation, it certainly provides power packing abilities.

To start with , this being my first blog, I would like to mention How would I like to unfold the topics.

To begin with , the first mention the VB script can do to automation is running scripts in batches. Well, you may think, there are tools like Test Batch runner, Multitestmanager, QC batch run program, but all of these have their own disadvantage. Either they can run only those scripts that are located locally/shared or they can be run with Quality center effectively. The quality center batch run utility( the one that you launch from QC after selecting tests) can run only those tests that are from single test set. If you want to run tests from multiple test sets in quality center, you have to run in separate batches.

Okay lets move on to what VB script can power our batch runs. QTP has innumerous object functions/libraries that VB script can access. These collectively are called QuickTest Professional Automation Object Model.

To run a batch of scripts, we have to following activities
  1. Launch QTP application.
  2. Connect to QC and Open the test ( or from locally defined path)
  3. Add/Check resources
  4. Add/Check Recovery scenarios
  5. Set Global Options
  6. Set Test parameters
  7. Set Test results options
  8. Run the test

    For item 1 From the Automation Object Model, the objects that we need to look at are CreateObject("QuickTest.Application") . The following code creates a qtp object and launches the QTP instance.

    Set appQTP=CreateObject("QuickTest.Application")
    If appQTP.launched <> True then 'Launch QTP application

    If Err.number <> 0 Then
    strErrMsg = "Error occured while Attempting to launch QTP" _
    &vbNewLine & Err.Description
    wscript.echo strErrMsg
    End If
    End if
    * Remove the code in blue if you arent trapping error using On error Resume next


    Related Posts Plugin for WordPress, Blogger...