Test Batch Runner - Run QTP Scripts from xls file

To run QTP Scripts from a xls file we need to use QTP AOM. First we have to write following code in a vbs file and save it anywhere on your system.

Option Explicit

Dim qtp 
Set qtp =CreateObject("QuickTest.Application")
qtp.Launch
qtp.Visible=True


Dim xl,bk,s
Set xl=createobject("Excel.application")
Set bk=xl.Workbooks.Open("D:\QTPScripts\Test Batch Runner\TestBatchRunner.xls")
Set s=xl.ActiveWorkbook.Worksheets("Sheet1")
Dim RowNo
RowNo=2
While trim(lcase(s.cells(RowNo,1)))<>"end"
qtp.Open s.cells RowNo,1
Dim qtpTest

'Assign the data table path 
qtp.Test.Settings.Resources.DataTablePath = s.cells(RowNo,2)

' Results
Dim qtpResults
                        Set qtpResults = CreateObject("QuickTest.RunResultsOptions") 
'run the test
qtp.Test.Run  qtpResults,True
RowNo=RowNo+1
Wend
'Release Objects
Set qtp=nothing
bk.Close
Set s=Nothing
Set bk=nothing
Set xl=nothing


change the workbook path as per your workbook.
Either use the following format for your xls file





or adjust the script as per ur file format. 

Double click the vbs file and it should run all the scripts one by one. 

Comments

  1. cool script, i'm having problems saving the results to a specific directory

    ReplyDelete
  2. Hi Ashish,

    I have implemented a .xls file which acts as my driver script to run QTP Scripts.I run a batch job of about 200 scripts at a time which runs absolutely fine. I currently need to write a code in the same .xls file which will allow me to generate a Dashboard HTML Report which when generated will give me the the count of passed and failed test cases. How can it be achieved? Do i need to use HTML DOM for that?
    Thanks in Advance

    ReplyDelete
  3. Hi Ashish,

    I am getting error "Cannot user parenthesis when calling a Sub".

    Could you please help me out on this.

    Regards
    Sunil Jangir
    9560530606

    ReplyDelete
  4. Hi Ashish,

    I am getting error "Cannot user parenthesis when calling a Sub".

    Could you please help me out on this.

    Regards
    Sunil Jangir
    9560530606

    ReplyDelete
    Replies
    1. Sure Sunil,

      Did you made any changes in the code? , do you know on which line you are getting this error ?

      This error means that you have used brackets where you are not taking return values in a variable.

      Delete
    2. please use:
      Option Explicit

      Dim qtp
      Set qtp =CreateObject("QuickTest.Application")
      qtp.Launch
      qtp.Visible=True

      Dim xl,bk,s
      Set xl=createobject("Excel.application")
      Set bk=xl.Workbooks.Open("D:\QTP_FRAMEWORK\TestData\ExcelDataFile\TestSuite.xls")
      Set s=xl.ActiveWorkbook.Worksheets("Sheet1")
      Dim RowNo
      RowNo=2
      While trim(lcase(s.cells(RowNo,1)))<>"end"

      qtp.Opens.cells RowNo,1
      Dim qtpTest

      'Assign the data table path
      qtp.Test.Settings.Resources.DataTablePath = s.cells(RowNo,2)

      ' Results
      Dim qtpResults
      Set qtpResults = CreateObject("QuickTest.RunResultsOptions")
      'run the test
      qtp.Test.Run qtpResults,True
      RowNo=RowNo+1
      Wend
      'Release Objects
      Set qtp=nothing
      bk.Close
      Set s=Nothing
      Set bk=nothing
      Set xl=nothing

      Delete
    3. Thanks a ton! I will appreciate you help. I believe in one old quote:

      "Those who help others, God helps them"

      Regards
      Sunil Jangir

      Delete
  5. Hi I am having a problem with test batch runner in uft.
    previously we were using Multi test manager to execute batches. But now uft is not able to support Multi Test Manager. so we are planning to run our suites with Test Batch Runner.
    Previously we were using code

    ' Create an Instance of Multi Test Manager
    Set oMTM = CreateObject("MultiTestManager.Application")
    oMTM.Visible = False

    ' Run the scripts
    oMTM.Load "D:\CNX_CoreAutomation\RegionCronJob\xyz.mtm"

    oMTM.Run

    while ( oMTM.IsRunning )
    Wend

    Set oRunSettingss = Nothing
    Set oReportSettings = Nothing

    oMTM.Quit
    Set oMTM = Nothing


    BUT NOW WE ARE HAVING PROBLEM IN CREATING OBJECT OF TEST BATCH RUNNER.

    "Set oMTM = CreateObject("TestBatchRunner.Application")"

    QTP is throwing an error Activex can't create object
    Does any one have this solution?

    ReplyDelete

Post a Comment

Popular posts from this blog

Selenium: db and excel data into maps

Python: get entire workbook data cell by cell