Generating HTML report in QTP


Generating HTML report in QTP:

I have been planning to develop “Customised HTML reporting module(nano)”.I am sure i’ll do it soon,it’s often said “deeds are more important than words”.I am publishing a simple html reporting as of now.The reporting is very basic but you can customize it as per your needs.Here it’s–>

‘******************************************************************

'Purpose:Generating HTML report in QTP
'Author:QTP Lab:--A touch of madness
'Website:https://automationlab09.wordpress.com
'Published:28/05/2010
'**************************************************
Function Create_HTML_Logfile(sHTMLres_path)
Dim fso   'As FileSystemObject
Dim myfile
Set fso=CreateObject("Scripting.filesystemobject") 'Creates a new file system object.
If (fso.Fileexists(sHTMLres_path)) Then
else
fso.createtextfile (sHTMLres_path)
End If
Set myfile=fso.CreateTextFile(sHTMLres_path,True)
'HTML HEADER FORMATTING BEGINS
myfile.WriteLine("<HTML>")
myfile.WriteLine("<HEAD>")
myfile.WriteLine("<TITLE>Automation Run Results</TITLE>")
myfile.WriteLine("</HEAD>")
myfile.WriteLine("<BODY bgcolor='#314D01'>")
myfile.WriteLine("<table cellSpacing='0' style='width:90%' cellPadding='0' align='center'  border='0'  bordercolor='#eeefff' summary='Main'>")
myfile.WriteLine("<tr>")
myfile.WriteLine("Run Results")
myfile.WriteLine("</tr>")
myfile.WriteLine("<tr>")
myfile.WriteLine("<td align='center' style='color:red'>")
myfile.WriteLine("<table cellSpacing='0' style='width:90%' cellPadding='0' align='center'  border='1'  bordercolor='#efefff' summary='Inside'>")
myfile.WriteLine("<TR>")
myfile.WriteLine("Time")
myfile.WriteLine("Test Object")
myfile.WriteLine("Error No.")
myfile.WriteLine("Error Descrn.")
myfile.WriteLine("Expected Result")
myfile.WriteLine("Actual Result")
myfile.WriteLine("</TR>")
myfile.WriteLine("</table>")
myfile.WriteLine("</td>")
myfile.WriteLine("</tr>")
myfile.WriteLine("</table>")
myfile.WriteLine("</BODY>")
myfile.WriteLine("</HTML>")
End Function
'Usage:
Create_HTML_Logfile "C:\hello.html"

Expected Result:

generating html result in qtp

html result in qtp

Advertisements

One response to this post.

  1. Posted by Anonymous on May 11, 2012 at 10:49 am

    good one…

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: