05-16-2013, 11:28 AM
Hi All,
I am running qtp scripts in batch mode using the following code,
Now i want to insert description of that particular scenario along with its name
Currently using below code:
'Aim : Gets folders and subfolders and runs test scripts
'********************************************************
'Aim :To writes result in excel sheet
'*************************************************************************
********************************************************
Please suggest me with other piece of code.
Regards,
Prashanth.
I am running qtp scripts in batch mode using the following code,
Now i want to insert description of that particular scenario along with its name
Currently using below code:
Code:
set qtp = CreateObject("Quicktest.Application")
qtp.Launch
qtp.visible = True
call moduledriver("EXECUTABLEFOLDER")
qtp.quit
'Aim : Gets folders and subfolders and runs test scripts
'********************************************************
Code:
Function moduledriver(modulename)
set fso = createobject("Scripting.FilesyStemObject")
set module= fso.getfolder("D:\Sanity\"&modulename)
set folders=module.subfolders
i=2
for each tmp in folders
testname = tmp.name
qtp.open tmp.path
qtp.test.run
res=qtp.test.lastrunresults.status
'ts = replace (replace(now,"/","_"),":","_")
t1=time
t2=date
call writeresults(modulename,i,testname,res,t1,t2)
i=i+1
next
end function
'Aim :To writes result in excel sheet
'*************************************************************************
Code:
'function writeresults(modulename,rowno,testname,res,t1,t2)
'set xl= CreateObject("Excel.Application")
'set wb = xl.workbooks.open("D:\Sanity\Sanity_Result\Results.xls")
'ts = replace (replace(now,"/","_"),":","_")
'wb.saveas "D:\Sanity\Sanity_Result\Results"&ts
'set ws= wb.worksheets(modulename)
'ws.cells(rowno,1) = testname
'ws.cells(rowno,2)= res
'ws.cells(rowno,3)= t1
'ws.cells(rowno,4)= t2
'wb.close
'xl.quit
'end function
function writeresults(modulename,rowno,testname,res,t1,t2)
set xl= CreateObject("Excel.Application")
set wb = xl.workbooks.open("D:\Sanity\Sanity_Result\Results.xls")
set ws= wb.Sheets("Sanity_TestSuite")
wsrange=ws.UsedRange.Rows.Count
'msgbox(wsrange)
ws.cells(wsrange+1,1) = testname
ws.cells(wsrange+1,2)= res
ws.cells(wsrange+1,3)= t1
ws.cells(wsrange+1,4)= t2
wb.Save
wb.close
xl.quit
end function
********************************************************
Please suggest me with other piece of code.
Regards,
Prashanth.