Header Ads

Generate HTMl Report Through QTP

The objective of this post is to show the colorful report coming out from QTP.Normally QTP reports are not so clear about the details. With raw report we can hardly take any call. All the testcases failed during automation run needs to be analyzed to check the validity of having a bug. There could be n number of bugs or can be one bug causing n numbers of failures. This type of report would give a colorful representation about failures.

Test report analysis is part an parcel of a automator. It is painful and laborious job.We can use some kind of automation by making the test result visually good and utility friendly. The utility will determine the analysis and report.
This Coding is completely done by Nilanjan--My Friend...Some part has been modified by me..
Check it and use it as per your need....
Objective of this code to create an HTML test report through QTP
HTML Report Out:

Function WriteResultsData()Dim valisTestCaseID =”1″
‘Environment.Value(”tion_no”)
sProducts=”class”
‘Environment.Value(”Product_name”)
sTestcaseDesc=”Animesh”
‘Environment.Value(”Customer_Name”)
sPolicy_ID=”Excell line”&(sTestCaseID+1)
‘// Change the below path
Screen_Shot_Path= “D:\Animesh\Temp\Problem_new_”
dim sTablePath1
mynow=now
mynow=replace( mynow,” “,”_”)
mynow=replace( mynow,”/”,”_”)
mynow=replace( mynow,”:”,”_”)
sScreenPath=Screen_Shot_Path + sname + mynowsScreenPath1=Screen_Shot_PathDesktop.CaptureBitmap sScreenPath & “.png”,true
sScreenPath1=sScreenPath1+”.html”color=”Green”
Dim fso, f, ts
Const ForReading = 1, ForWriting = 2,ForAppending = 8
sScreenPath= sScreenPath & “.png”
Set fso = CreateObject(”Scripting.FileSystemObject”)
filespec=sScreenPath1If (fso.FileExists(filespec)) Then
Set f = fso.OpenTextFile(sScreenPath1, ForReading)
ReadAllTextFile = f.ReadAll
ReadAllTextFile=replace(ReadAllTextFile,”
Company name Automation Testing Reports
“,”")
ReadAllTextFile=replace(ReadAllTextFile,”
TestCase ID
Client_Name
Products
Policy_ID
Date
ScreenShotPath
TestCase ID
Client_Name
Products
Policy_ID
Date
ScreenShotPath
“,”")
ReadAllTextFile=replace(ReadAllTextFile,”
TestCase ID
Client_Name
Products
Policy_ID
Date
ScreenShotPath
“,”")ReadAllTextFile= replace ( ReadAllTextFile,”
“,”")ReadAllTextFile= replace ( ReadAllTextFile,”
“,”")ReadAllTextFile= replace ( ReadAllTextFile,”“,”")
Set f = fso.OpenTextFile(sScreenPath1, ForWriting, True)
f.writeline”
Company name Automation Testing Reports
TestCase ID
Client_Name
Products
Policy_ID
Date
ScreenShotPath
“& ReadAllTextFile &”
“& sTestCaseID &”
“&sTestcaseDesc&”
“& sProducts &”
“& sPolicy_ID &”
“& Now &”
” & sScreenPath &”

f.close
Else
set myfile=fso.CreateTextFile (sScreenPath1 ,true) ‘ Create a file.
myfile.writeline”
Company name Automation Testing Reports
TestCase ID
Client_Name
Products
Policy_ID
Date
ScreenShotPath
“& sTestCaseID &”
“&sTestcaseDesc&”
“& sProducts &”
“& sPolicy_ID &”
“& Now &”
” & sScreenPath &”

myfile.close
End If
end function


another way ... It will display the error number and description

Public Function FunctionName(Object, Method, Arguments, retVal).
Proposed Function Body...
/* Code */
Set Props = Object.GetTOProperties
PropsCount = Props.Count
Desc = "Operation Failed." & vbCrLf & "Object Description: " & vbCrLf
For i = 0 To PropsCount - 1
PropName = Props(i).Name
PropValue = Props(i).Value
Desc = Desc & PropName & " = " & PropValue & vbCrLf
Next

reporter.ReportEvent micFail , "Error " , Desc & vbCrLf & "Failed On: " & Method
/*End Code */

With such representation of defects/failures,we can easily identify the design/process and tool issues. These will help in the below way:

  1. Reduce manual labor cost
  2. Improve product quality
  3. Increase testing flexibility
  4. free up automation and manual testers for other testing.
  5. It will make the defects/failures visible. It shows how defects can be prevented from propagating to production.
  6. Easy understandable format for all level of management.





Powered by Blogger.