You can try the below code... let's chk it if it can be useful for u...
''<Procedure>
''<name> InsertIntoHTMLReport</name>
''<description> It is the main parent function that checks the availability
of the text log file for the current date and if it is present then it
calls another function to update this text file, else it call function to
create text file and then update it with result logs. </description>
''<param name="strStepName">[in] The calling function name or the Step
name</param>
''<param name="strStepShortDesc">[in] Short Description of Step or calling
function</param>
''<param name="strExpectedResult">[in] Expected Result description</param>
''<param name="blnStatus">[in] "True" for passed validation, "False" for
failed validation</param>
''<param name="strLogfilePath">[in] Result folder path where the html log
file needs to be created</param>
''<param name="blnImage">[in] True or False , True if SnapShot is required ,
False if not required </param>
''<returns> NIL</returns>
''<example>
''
'' Call InsertIntoHTMLReport( "Pearson Testing", "Testing Pearson
Scenarios", "Automation Success", True, "D:\QTP_Pearson\test_html",True)
''
''</example>
''<changelog>
'' Date Author Changes/Notes
''----------- ------------------
-----------------------
'' 28-Dec-2010 Shalabh Dixit Initial version.
''</changelog>
''</Procedure>
'''''*************************************************************************************************************************************************************************************************************
'''''*************************************************************************************************************************************************************************************************************
Public Sub InsertIntoHTMLReport(strStepName, strStepShortDesc,
strExpectedResult, blnStatus, strLogfilePath,blnImage)
On Error Resume Next
Dim dtMyDate
Dim strHTMLFilePath
dtMyDate = Day(Date) &"_"& MonthName(Month(Date),3) &"_"&
Year(Date)
strHTMLFilePath =strLogfilePath &"\HTML_Result_Log_"&
Environment.Value("TestName") &"_TestSuite_"& dtMyDate & ".txt"
If strLogfilePath <> "" Then
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If (objFSO.FileExists(strHTMLFilePath)) Then
Call UpdateHTMLReport(strStepName, strStepShortDesc,
strExpectedResult, blnStatus, strHTMLFilePath,strLogfilePath,blnImage)
Else
Call CreateHTMLReport(strHTMLFilePath)
Call UpdateHTMLReport (strStepName, strStepShortDesc,
strExpectedResult, blnStatus, strHTMLFilePath,strLogfilePath,blnImage)
End If
Else
Reporter.ReportEvent micFail, "ERROR. Log file path is not
specified", ""
End If
Set objFSO = Nothing
End Sub
''''''''''''''''''UpdateHTMLReport''''''''''''''''
''''''''''''''*********************************
''<Procedure>
''<name> UpdateHTMLReport</name>
''<description> This function updates the text log file as well as the QTP
embeded Result log.</description>
''<param name="strStepName">[in] The calling function name or the Step
name</param>
''<param name="strStepDesc">[in] Short Description of Step or calling
function</param>
''<param name="strExpectedResult">[in] Expected Result description</param>
''<param name="blnStatus">[in] "True" for passed validation, "False" for
failed validation</param>
''<param name="strHTMLFilePath">[in] The text file path which needs to be
updated and transformed into html file.</param>
''<param name="strLogfilePath">[in] Result folder path where the html log
file needs to be created</param>
'<param name="blnImage">[in] True or False , True if SnapShot is required ,
False if not required </param>
''<returns> NIL</returns>
''<example>
'' strHTMLFilePath =strLogfilePath &"\HTML_Result_Log_"&
Environment.Value("TestName") &"_TestSuite_"& dtMyDate & ".txt"
'' Call UpdateHTMLReport( "Pearson Testing", "Testing Pearson
Scenarios", "Automation Success", True,
strHTMLFilePath,"D:\QTP_Pearson\test_html",True)
''
''</example>
''<changelog>
'' Date Author Changes/Notes
''----------- ------------------
-----------------------
'' 28-Dec-2010 Shalabh Dixit Initial version.
''</changelog>
''</Procedure>
'''''*************************************************************************************************************************************************************************************************************
'''''*************************************************************************************************************************************************************************************************************
Public Sub UpdateHTMLReport(strStepName, strStepDesc, strExpectedResult,
blnStatus, strHTMLFilePath,strLogfilePath,blnImage)
On Error Resume Next
Dim dtMyDate
Dim qtApp
Dim strMyStatus
Dim strVarStatus
Dim strColor
Dim dtExecutionTime
Dim a, intHour , intMinute , intSec
Const ForWriting = 2
Const ForAppending = 8
dtMyDate = Day(Date) &"_"& MonthName(Month(Date),3) &"_"&
Year(Date)
If UCase(Trim(blnStatus)) = Ucase("True") Then
strMyStatus = "Pass"
strColor ="GREEN"
Elseif UCase(Trim(blnStatus)) = Ucase("False") Then
strMyStatus = "Fail"
strColor ="RED"
End If
Set qtApp = CreateObject("QuickTest.Application")
strTimeStamp = Day(Date) & Month(Date) & Year(Date) &"_"&
Hour(Time) & Minute(Time) & Second(Time)
If UCase(Trim(blnImage)) =UCase("True")Then
'' If blnStatus <> "True" Then
Dim strStatusFileName,
strStatusFilePath,strStatusStepFilePath
strStatusFileName = "Execution_status_image_"&
strTimeStamp & ".bmp"
strStatusFilePath = strLogfilePath & "\" &
strStatusFileName
qtApp.Visible = False
Wait(1)
Desktop.CaptureBitmap strStatusFilePath, True
qtApp.Visible = True
strStatusStepFilePath = strStatusFilePath
'' Else
'' strStatusStepFilePath = "NA"
'' End If
ElseIf UCase(Trim(blnImage)) =UCase("False") Then
strStatusStepFilePath = "NA"
Else
Reporter.ReportEvent micWarning,
"InsertIntoHTMLReport","blnImage parameter value: "& blnImage &" is not
passed properly. Please pass boolean value."
Exit Sub
End If
a= "0"
intHour = Hour(Time)
intMinute = Minute(Time)
intSec = Second(Time)
If Len(intHour) < 2 Then
intHour = a & intHour
End If
If Len(intMinute) < 2 Then
intMinute = a & intMinute
End If
If Len(intSec) < 2 Then
intSec = a & intSec
End If
dtExecutionTime =Day(Date) &"-"& MonthName(Month(Date),3)
&"-"& Year(Date)&", "& intHour &":"& intMinute &":"& intSec
Set fso = CreateObject ("Scripting.FileSystemObject")
Set objHTMLTextFile = fso.OpenTextFile(strHTMLFilePath, 8,
true)
objHTMLTextFile.WriteLine("<tr>")
objHTMLTextFile.WriteLine("<td><font color=BLACK
face=ARIAL>"& Environment.Value("ActionName") &"</font></td>")
objHTMLTextFile.WriteLine("<td><font color=BLACK
face=ARIAL>"& strStepName &"</font></td>")
objHTMLTextFile.WriteLine("<td><font color=BLACK
face=ARIAL>"& strStepDesc &"</font></td>")
objHTMLTextFile.WriteLine("<td><font color=BLACK
face=ARIAL>"& strExpectedResult &"</font></td>")
objHTMLTextFile.WriteLine("<td ><font color=" & strColor &"
face=ARIAL> "& strMyStatus &" </font></td>")
objHTMLTextFile.WriteLine("<td ><font color=BLACK
face=ARIAL>"& dtExecutionTime &"</font></td>")
If strStatusStepFilePath ="NA" Then
objHTMLTextFile.WriteLine("<td ><font color=BLACK
face=ARIAL>"& strStatusStepFilePath &"</font></td>")
Else
objHTMLTextFile.WriteLine("<td><font color=" & strColor
&" face=ARIAL><a href='"& strStatusStepFilePath & "'>"&
strStatusStepFilePath & "</a></font></td>")
End If
objHTMLTextFile.WriteLine("</tr>")
If strMyStatus = "Pass" Then
strVarStatus = micPass
Reporter.ReportEvent strVarStatus , strStepName ,
strStepDesc & ", Expected Result : <" & strExpectedResult &">.",
strStatusStepFilePath
Elseif strMyStatus ="Fail" Then
strVarStatus = micFail
Reporter.ReportEvent strVarStatus , strStepName ,
strStepDesc & " , Expected Result : <" & strExpectedResult &
">.",strStatusStepFilePath
End If
objHTMLTextFile.Close
Set objHTMLTextFile = Nothing
Set qtApp = Nothing
Set fso = Nothing
End Sub
Regards
Shalabh Dixit
On Fri, Apr 8, 2011 at 5:32 PM, Ramya harini <[email protected]> wrote:
> Hi QTP users,
>
> If any one has the code for HTML way result report in vbscript.pls share it
> across!
>
> Thanks
> Ramya
>
> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en