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.
cool script, i'm having problems saving the results to a specific directory
ReplyDeletewhat is the issue u r facing ?
ReplyDeleteHi Ashish,
ReplyDeleteI 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
Hi Ashish,
ReplyDeleteI am getting error "Cannot user parenthesis when calling a Sub".
Could you please help me out on this.
Regards
Sunil Jangir
9560530606
Hi Ashish,
ReplyDeleteI am getting error "Cannot user parenthesis when calling a Sub".
Could you please help me out on this.
Regards
Sunil Jangir
9560530606
Sure Sunil,
DeleteDid 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.
please use:
DeleteOption 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
Thanks a ton! I will appreciate you help. I believe in one old quote:
Delete"Those who help others, God helps them"
Regards
Sunil Jangir
Hi I am having a problem with test batch runner in uft.
ReplyDeletepreviously 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?