New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE
Highlighted
Absent Member.
Absent Member.
4922 views

Generate HTML Report using UFT

'Call fEnterReport()

Public Function fGetReportHeader()
reportHeader ="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><HTML><HEAD><TITLE>Tieto - custom QTP generated report</TITLE>"&vbCrLf&_
"<META http-equiv='Content-Type' content='text/html; charset=windows-1250'><style type='text/css'>#header {font-family: sans-serif; font-size: 14px; color: #333333;} B {font-family: sans-serif; font-size: 11px; color: #333333;} I {font-weight: bold; font-family: sans-serif; font-size: 11px; color: #000000;} DT {font-family: sans-serif; font-size: 11px; color: #343434;}</style>"&vbCrLf&_
"<script type='text/javascript'><!--"&vbCrLf&_
"// showHide function expands / collapses individual TA modules"&vbCrLf&_
"function showHide(elementid){"&vbCrLf&_
" if (document.getElementById(elementid).style.display == 'none'){"&vbCrLf&_
" document.getElementById(elementid).style.display = '';"&vbCrLf&_
" } else {"&vbCrLf&_
" document.getElementById(elementid).style.display = 'none';"&vbCrLf&_
" }"&vbCrLf&_
"}"&vbCrLf&_
""&vbCrLf&_
"function ToggleAll(){"&vbCrLf&_
" var eID = 1;"&vbCrLf&_
" if (document.getElementById('toggle').innerHTML.toLowerCase() == '<dt>expand all</dt>') {"&vbCrLf&_
" document.getElementById('toggle').innerHTML = '<dt>Collapse All</dt>';"&vbCrLf&_
" buttonVal = ''; "&vbCrLf&_
" } else {"&vbCrLf&_
" document.getElementById('toggle').innerHTML = '<dt>Expand All</dt>';"&vbCrLf&_
" buttonVal = 'none';"&vbCrLf&_
" }"&vbCrLf&_
""&vbCrLf&_
" while (document.getElementById('mod'+eID)!= null) {"&vbCrLf&_
" document.getElementById('mod'+eID).style.display = buttonVal;"&vbCrLf&_
" eID = eID + 1;"&vbCrLf&_
" }"&vbCrLf&_
"}"&vbCrLf&_
""&vbCrLf&_
""&vbCrLf&_
"// following 2 functions (moduleHeaderLightsUp, moduleHeaderLightsDown) changes color of individual TA module header"&vbCrLf&_
"function moduleHeaderLightsUp(modHeaderElement) {"&vbCrLf&_
" modHeaderElement.style.backgroundColor='#ffffcc';"&vbCrLf&_
"}"&vbCrLf&_
"function moduleHeaderLightsDown(modHeaderElement) {"&vbCrLf&_
" modHeaderElement.style.backgroundColor='#cccccc';"&vbCrLf&_
"}"&vbCrLf&_
""&vbCrLf&_
"//--> </script>"&vbCrLf&_
""&vbCrLf&_
"</Head><BODY leftmargin=2 topmargin=0 text='Black' link='Black' vlink='Black' alink='Black' bgcolor='#ffffff'>"&vbCrLf&_
"<TABLE bgcolor='#ffffff' cellspacing=0 cellpadding=2 width='665'>"&vbCrLf&_
"<TR><TD id='header' colspan='4' bgcolor='#1A2974' align='center'><dt><font size='6' style = ""font-family:Calibri"" color='#ffffff'><strong>Test Execution Report</strong></font></dt></TD></td></TR>"&vbCrLf&_
"<TR><TD></TD></TR><TR><TD></TD></TR>"&vbCrLf&_
"<TR><TD width='200' bgcolor='#FBF1CE' colspan='4'><dt><font size='4' style = ""font-family:Calibri"" color=#000000><strong>Execution Report<strong></font></dt></TD></TR>"&vbCrLf&_
"<TR><TD width='140' bgcolor='#B6C0C7'><dt><font size='2' style = ""font-family:Calibri"" color=#000000><strong>TEST CASE:<strong></font></dt><TD width='400' bgcolor='#B6C0C7'><dt><font size='3' style = ""font-family:Calibri"" color=#000000><strong>"&Environment.Value("TestName")&"<strong></dt></TD><TD width='17%' rowspan='4' align='center' valign='middle' bgcolor='#2CA22C' style = ""font-family:Calibri""><strong> PASS</strong></TD></TR>"&vbCrLf&_
"<TR><TD width='140' bgcolor='#B6C0C7'><dt><font size='2' style = ""font-family:Calibri"" color=#000000><strong>START TIME:<strong></font></dt><TD width='400' bgcolor='#B6C0C7'><dt><font size='2' style = ""font-family:Calibri"" color=#000000><strong>2015.07.01 13:14<strong></dt></TD></TR>"&vbCrLf&_
"<TR><TD width='140' bgcolor='#B6C0C7'><dt><font size='2' style = ""font-family:Calibri"" color=#000000><strong>END TIME:<strong></font></dt><TD width='400' bgcolor='#B6C0C7'><dt><font size='2' style = ""font-family:Calibri"" color=#000000><strong>2015.07.01 13:14<strong></dt></TD></TR>"&vbCrLf&_
"<TR><TD width='140' bgcolor='#B6C0C7'><dt><font size='2' style = ""font-family:Calibri"" color=#000000><strong>TOTAL DURATION:<strong></font></dt><TD id ='totalDuration' width='400' bgcolor='#B6C0C7'><dt><font size='2' style = ""font-family:Calibri"" color=#000000><strong>00:14:35<strong></B></TD></TR>"&vbCrLf&_
"<TR><TD></TD></TR><TR><td height='22'><button style='height: 20px; width: 100px;background-color: #cdcdcd;' id='toggle' onclick=javascript&colon;ToggleAll();><dt>Expand All</dt></button></td></TR><TR><TD></TD></TR><TR><TD></TD></TR>"&vbCrLf&_
"<TR><TD width='200' bgcolor='#FBF1CE' colspan='4'><dt><font size='4' style = ""font-family:Calibri"" color=#000000><strong>Execution Details<strong></font></dt></TD></TR>"&vbCrLf&_
"</TABLE>"
fGetReportHeader = reportHeader
End Function

Public Function fCreateExecutionDetailsHeader()
ExecutionDetailsHeader = "</TABLE>"&vbCrLf&_
"<TABLE border=""1"" bgcolor='#ffffff' cellspacing=0 cellpadding=2 width='665'>"&vbCrLf&_
"<TR><TD width='10%' bgcolor='#D5B2A1' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>Serial No.<strong></font></dt></TD>"&vbCrLf&_
"<TD width='40%' bgcolor='#D5B2A1' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>Function Name<strong></font></TD>"&vbCrLf&_
"<TD width='10%' bgcolor='#D5B2A1' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>Iteration No<strong></font></TD>"&vbCrLf&_
"<TD width='10%' bgcolor='#D5B2A1' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>Execution Time<strong></font></TD>"&vbCrLf&_
"<TD width='14%' bgcolor='#D5B2A1' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>Status<strong></font></TD></TR></TABLE>"
fCreateExecutionDetailsHeader = ExecutionDetailsHeader
End Function

Public Function fEnterReport(ReportType,ReportStatus,ReportText)
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\TA_VF_Framework\Reports\abc.html") Then
objFSO.DeleteFile("C:\TA_VF_Framework\Reports\abc.html")
objFSO.CreateTextFile("C:\TA_VF_Framework\Reports\abc.html")
Else
objFSO.CreateTextFile("C:\TA_VF_Framework\Reports\abc.html")
End If
'Code Header and Expand All Buton
Set objReportFile = objFSO.GetFile("C:\TA_VF_Framework\Reports\abc.html").OpenAsTextStream(8,-2)
objReportFile.writeline fGetReportHeader()
'Code Serial No and Execution Details
objReportFile.writeline fCreateExecutionDetailsHeader()
Select Case ReportType
Case "Function Execution"
Environment.Value("REPORT_CONTENT") = Environment.Value("REPORT_CONTENT")&vbCrLf&_
"<TABLE onMouseOver=javascript&colon;moduleHeaderLightsUp(this); onMouseOut=javascript&colon;moduleHeaderLightsDown(this); onclick=javascript&colon;showHide('mod"&Environment.Value("FUN_SEQ_NO")&"'); cellspacing=1 cellpadding=1 width='665' bgcolor='#CCCCCC'>"&vbCrLf&_
"<TR><TD width='75' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>"&Environment.Value("FUN_SEQ_NO")&"<strong></font></dt></TD>"&vbCrLf&_
"<TD width='313' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>"&Environment.Value("FUNCTION_NAME")&"</strong></font></TD>"&vbCrLf&_
"<TD width='76' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>ITR"&ITR_ID&"</strong></font></TD>"&vbCrLf&_
"<TD width='76' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>13 sec</strong></font></TD>"&vbCrLf&_
"<TD width='108' bgcolor='#2CA22C' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>PASS<strong></font></TD></TR></Table>"
Case "Informational"
Environment.Value("REPORT_CONTENT") = Environment.Value("REPORT_CONTENT")&vbCrLf&_
"<TABLE id='mod"&Environment.Value("FUN_SEQ_NO")&"' style='display:none' cellspacing=1 cellpadding=1 width='665' bgcolor='#ffffff'>"&vbCrLf&_
"<TR><TD width='75' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>PASS</strong></font></TD>"&vbCrLf&_
"<TD bgcolor='#2CA22C' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>ABC<strong></font></TD></TR></Table>"

End Select

objReportFile.writeline Environment.Value("REPORT_CONTENT")
Set objFSO = Nothing
End Function

'Working COde
'objReportFile.writeline "<table cellspacing=1 cellpadding=1 width='665' bgcolor='#FFFFFF'><tr bgcolor='#dedede'><td colspan='2'>"&vbCrLf&_
'"<TABLE onMouseOver=javascript&colon;moduleHeaderLightsUp(this); onMouseOut=javascript&colon;moduleHeaderLightsDown(this); onclick=javascript&colon;showHide('mod1'); cellspacing=1 cellpadding=1 width='663' bgcolor='#CCCCCC'>"&vbCrLf&_
'"<TR><TD width='75' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>1<strong></font></dt></TD>"&vbCrLf&_
'"<TD width='313' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>Open CAB Application</strong></font></TD>"&vbCrLf&_
'"<TD width='76' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>ITR1</strong></font></TD>"&vbCrLf&_
'"<TD width='76' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>13 sec</strong></font></TD>"&vbCrLf&_
'"<TD width='109' bgcolor='#2CA22C' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>PASS<strong></font></TD></TR></Table>"&vbCrLf&_
'"<TABLE id='mod1' style='display:none' cellspacing=1 cellpadding=1 width='663' bgcolor='#ffffff'>"&vbCrLf&_
'"<TR><TD width='10%' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>PASS</strong></font></TD>"&vbCrLf&_
'"<TD bgcolor='#2CA22C' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>ABC<strong></font></TD></TR>"&vbCrLf&_
'"<TR><TD width='10%' bgcolor='#FFFAFA' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>FAIL</strong></font></TD>"&vbCrLf&_
'"<TD bgcolor='#2CA22C' align = 'center'><dt><font size='2.5' style = ""font-family:Calibri"" color=#000000><strong>BBC<strong></font></TD></TR></Table>"
'

0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.


'#######################################################

Function tcReportFileCreate (ReportFolderPath, TestChainName, version)

' REPORT FOLDER CHECK (Create if not exists)
If FolderExists(ReportFolderPath) = False Then
FolderCreate ReportFolderPath
End If

' Create fso object
Set fso = CreateObject("Scripting.FileSystemObject")
Do While Instr(TestChainName," ") <> 0
TestChainName = Replace(TestChainName, " ", "")
Loop
' Define html file name
Environment("ReportFilePath") = ReportFolderPath&"/" & TestChainName & "("&Year(Now)&"."&Right("0"&Month(Now),2)&"."&Right("0"&Day(Now),2)&"-"&Right("0"&Hour(Now),2)&"."&Right("0"&Minute(Now),2)&"."&Right("0"&Second(Now),2)&").html"
' Create file
fso.CreateTextFile(Environment("ReportFilePath"))
' Create Report main variables
Environment("reportHeader") = ""&VbCrLf
Environment("reportContent") = ""&VbCrLf
Environment("OverallStatus") = "passed"
Environment("OverallStatusColor") = "#CCFFCC"
Environment("FailedCounter") = 0
End Function

 

'#######################################################
' tcReportHeaderGet
'
' Description:
' This public function creates report's header
'
'
'
'#######################################################
Function tcReportHeaderGet ()

' REPORT HEADER GENERATION
tcReportHeaderGet = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><HTML><HEAD><TITLE>Tieto - custom QTP generated report</TITLE>"&vbCrLf&_
"<META http-equiv='Content-Type' content='text/html; charset=windows-1250'><style type='text/css'>#header {font-family: sans-serif; font-size: 14px; color: #333333;} B {font-family: sans-serif; font-size: 11px; color: #333333;} I {font-weight: bold; font-family: sans-serif; font-size: 11px; color: #000000;} DT {font-family: sans-serif; font-size: 11px; color: #343434;}</style>"&vbCrLf&_
"<script type='text/javascript'><!--"&vbCrLf&_
"// showHide function expands / collapses individual TA modules"&vbCrLf&_
"function showHide(elementid){"&vbCrLf&_
" if (document.getElementById(elementid).style.display == 'none'){"&vbCrLf&_
" document.getElementById(elementid).style.display = '';"&vbCrLf&_
" } else {"&vbCrLf&_
" document.getElementById(elementid).style.display = 'none';"&vbCrLf&_
" }"&vbCrLf&_
"}"&vbCrLf&_
""&vbCrLf&_
"function ToggleAll(){"&vbCrLf&_
" var eID = 1;"&vbCrLf&_
" if (document.getElementById('toggle').innerHTML.toLowerCase() == '<dt>expand all</dt>') {"&vbCrLf&_
" document.getElementById('toggle').innerHTML = '<dt>collapse all</dt>';"&vbCrLf&_
" buttonVal = ''; "&vbCrLf&_
" } else {"&vbCrLf&_
" document.getElementById('toggle').innerHTML = '<dt>expand all</dt>';"&vbCrLf&_
" buttonVal = 'none';"&vbCrLf&_
" }"&vbCrLf&_
""&vbCrLf&_
" while (document.getElementById('mod'+eID)!= null) {"&vbCrLf&_
" document.getElementById('mod'+eID).style.display = buttonVal;"&vbCrLf&_
" eID = eID + 1;"&vbCrLf&_
" }"&vbCrLf&_
"}"&vbCrLf&_
""&vbCrLf&_
""&vbCrLf&_
"// following 2 functions (moduleHeaderLightsUp, moduleHeaderLightsDown) changes color of individual TA module header"&vbCrLf&_
"function moduleHeaderLightsUp(modHeaderElement) {"&vbCrLf&_
" modHeaderElement.style.backgroundColor='#ffffcc';"&vbCrLf&_
"}"&vbCrLf&_
"function moduleHeaderLightsDown(modHeaderElement) {"&vbCrLf&_
" modHeaderElement.style.backgroundColor='#cccccc';"&vbCrLf&_
"}"&vbCrLf&_
""&vbCrLf&_
"//--> </script>"&vbCrLf&_
""&vbCrLf&_
"</HEAD><BODY leftmargin=2 topmargin=0 text='Black' link='Black' vlink='Black' alink='Black' bgcolor='#ffffff'>"&vbCrLf&_
"<TABLE bgcolor='#ffffff' cellspacing=0 cellpadding=2 width='600'>"&vbCrLf&_
"<TR><TD id='header' colspan='2' width=560 bgcolor='#ffffff'><dt><font size='2' color='#555555'><strong>detailed test case report generator</strong></font></dt></TD></td></TR>"&vbCrLf&_
"<TR><TD width='140' bgcolor='#333333'><dt><font color=#ffffff>TEST CASE</font></dt><TD width='400' bgcolor='#eeeeee'><dt>"&Environment.Value("TestCaseName")&"</dt></TD><TD width='100' rowspan='4' align='center' valign='middle' bgcolor='"&Environment("OverallStatusColor")&"'><img src='icon\tcResult_"&Environment("OverallStatus")&".png'></TD></TR>"&vbCrLf&_
"<TR><TD width='140' bgcolor='#333333'><dt><font color=#ffffff>DATE / TIME</font></dt><TD width='400' bgcolor='#eeeeee'><dt>"&Year(Now)&"."&Right("0"&Month(Now),2)&"."&Right("0"&Day(Now),2)&" / "&Right("0"&Hour(Now),2)&":"&Right("0"&Minute(Now),2)&"</dt></TD></TR>"&vbCrLf&_
"<TR><TD width='140' bgcolor='#333333'><dt><font color=#ffffff>TOTAL DURATION</font></dt><TD width='400' bgcolor='#eeeeee'><dt>"&secToMinSecConvert(DateDiff("s",Environment.Value("TestCaseExecutionTime_Start"), Time))&"</B></TD></TR>"&vbCrLf&_
"<TR><TD width='140' bgcolor='#333333'><dt><font color=#ffffff>XLS PATH </font></dt><TD width='400' bgcolor='#eeeeee'><a href='" & Environment.Value("DataTablePath") & "'><dt>" & Environment.Value("DataTablePath") & "</dt></a></TD></TR>"&vbCrLf&_
"</TABLE>"&vbCrLf&_
"<TABLE bgcolor='#ffffff' cellspacing=0 cellpadding=0 width='760'><tr><td>"&vbCrLf&_
""&vbCrLf&_
"<table cellspacing=0 cellpadding=0><tr>"&vbCrLf&_
"<td height='22'><button style='height: 20px; width: 100px;background-color: #cdcdcd;' id='toggle' onclick=javascript&colon;ToggleAll();><dt>expand all</dt></button></td>"&vbCrLf&_
"</tr></table>"&vbCrLf&_
"</tr></td>"&vbCrLf

End Function


'#######################################################
' tcReportUpdate
'
' Description:
' This public function creates html file and saves it
'
' Parameters:
' Input:
' ReportFolderPath (Location to where file is saved)
' TestChainName (Name of text file followed by date & time it was created)
'
'
'#######################################################
Function tcReportUpdate (ReportFolderPath)

' Open HTML report file for reading and read content
Set fso = CreateObject("Scripting.FileSystemObject")
Set myFile = fso.GetFile(Environment("ReportFilePath")).OpenAsTextStream(2,-2)

myFile.WriteLine tcReportHeaderGet
myFile.WriteLine Environment("reportContent")
myFile.WriteLine "</TABLE></DIV></DIV></DIV></BODY></HTML>"
myFile.Close

fQCStatusUpdate()

End Function


'################## TEST SUITE RUNNER REPORT FILE HANDLING #####################

' tsrInitialize
'
' Description:
' This public function initializes TSR:
' - creates TSR report file
' - declares TSR global variables
'
'#######################################################

Function tsrInitialize

Environment("tsrStatusColor") = "#CCFFCC"

' Create TSR report file (if not exists already)
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(Environment.Value("tsrFilePath")) = false Then

' Creates TSR folder (if it does not exist)
If FolderExists(Environment("tsrReportFolderPath")&"\details") = False Then
FolderCreate Environment("tsrReportFolderPath")&"\details"
End If

Set myFile = fso.CreateTextFile(Environment.Value("tsrFilePath"), true)
myFile.WriteLine tsrHeaderGenerate
myFile.Close
End If

' Refresh TSR report list
' msgBox Environment.Value("tsrFolder") & "testSuiteReports\"
SystemUtil.Run "C:\Windows\system32\cscript.exe", "tsrListGenerator.vbs", Environment.Value("tsrFolder") & "testSuiteReports\"
' SystemUtil.Run "C:\Windows\system32\cscript.exe", "tsrListGenerator.vbs", "E:\uftFW\tsr\testSuiteReports\"

End Function

'#######################################################
' tsrHeaderGenerate
'
' Description:
' This public function generates TSR's html header
'
'#######################################################

Function tsrHeaderGenerate
Dim tsrHeader

tsrHeader = _
"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>"&vbCrLf&_
"<HTML><HEAD><TITLE>TEST SUITE RUNNER</TITLE>"&vbCrLf&_
"<META http-equiv='refresh' content='120'; http-equiv='Content-Type' content='text/html; charset=windows-1250'><style type='text/css'>#header {font-family: sans-serif; font-size: 14px; color: #333333;} B {font-family: sans-serif; font-size: 11px; color: #333333;} I {font-weight: bold; font-family: sans-serif; font-size: 11px; color: #000000;} DT {font-family: sans-serif; font-size: 11px; color: #343434;}</style>"&vbCrLf&_
"<script type='text/javascript'><!--"&vbCrLf&_
"// following 2 functions (moduleHeaderLightsUp, moduleHeaderLightsDown) changes color of individual TA module header"&vbCrLf&_
"function tcLightsUp(tcLine) {"&vbCrLf&_
" tcLine.style.backgroundColor='#ccff33';"&vbCrLf&_
"}"&vbCrLf&_
"function tcLightsDown(tcLine) {"&vbCrLf&_
" tcLine.style.backgroundColor='#dedede';"&vbCrLf&_
"}"&vbCrLf&_
vbCrLf&_
"function funcNavigate(tcPage) {"&vbCrLf&_
" top.frames['tcDetails'].location.href = tcPage;"&vbCrLf&_
"}"&vbCrLf&_
""&vbCrLf&_
"//--> </script>"&vbCrLf&_
"</HEAD><BODY leftmargin=0 topmargin=6 text='Black' link='Black' vlink='Black' alink='Black' bgcolor='#ffffff'>"&vbCrLf&_
"<TABLE bgcolor='#ffffff' cellspacing=0 cellpadding=2 width='520'>"&vbCrLf&_
"<TR><TD width='520' bgcolor='#ffffff'><dt><font size='2' color='#555555'><strong>test suite runner</strong> <font size='1' color='#777777'>(executed by " & Environment.Value("UserName") & ")</font></dt></TD>"&vbCrLf&_
"</TR></TABLE>"&vbCrLf&_
"<TABLE bgcolor='#ffffff' cellspacing=1 cellpadding=0 width='520'>"&vbCrLf&_
"<tr><td align='center' bgcolor='#CCCCCC'><dt><strong>&nbsp; TEST SCENARIO</strong></dt></td><td align='center' valign='middle' width='66' bgcolor='#CCCCCC'><dt><strong>STATUS</strong></dt></td><td align='center' valign='middle' width='120' bgcolor='#CCCCCC'><dt><strong>DATE & TIME</strong></dt></td><td align='center' valign='middle' width='70' bgcolor='#CCCCCC'><dt><strong>DURATION</strong></dt></td><td align='center' valign='middle' width='20' bgcolor='#CCCCCC'><dt><strong>M</strong></dt></td></tr>"&vbCrLf&_
"" & vbCrLf

tsrHeaderGenerate = tsrHeader

End Function

 

 

'#######################################################
' tsrUpdate
'
' Description:
' This public function updates TSR report file
'
'#######################################################

Function tsrUpdate (updateType)

If updateType = "final" Then

' Preparation (modification of overall status)
If LCase(Environment("OverallStatus")) = "passed with warning" Then
Environment("OverallStatus") = "passed"
ElseIf LCase(Environment("OverallStatus")) = "failed" Then
Environment("tsrStatusColor") = "#FFCC99"
ElseIf LCase(Environment("OverallStatus")) = "critical" Then
Environment("tsrStatusColor") = "#FFCC99"
End If

tsrStatusColor = Environment("tsrStatusColor")
overallStatus = Environment("OverallStatus")
else

tsrStatusColor = "#CCFFFF"
overallStatus = "in progress"

End If

' Creation of relative test report path
ReportPathFragment = Split (Environment("ReportFilePath") , "\")
i = Ubound(ReportPathFragment)
ReportRelativePath = ReportPathFragment(i)

' Append new record to existing content
tsrContent = Environment.Value("tsrRecentFinishedContent") &_
"<tr style=background-color:#dedede; onMouseOver=javascript&colon;tcLightsUp(this); onMouseOut=javascript&colon;tcLightsDown(this); onclick=javascript&colon;funcNavigate('"& ReportRelativePath &"');><td align='left' width='300'><dt>" & Environment.Value("TestCaseName") & "</a></dt></td><td align='center' valign='middle' width='64' bgcolor='" & tsrStatusColor & "'><dt><font color='#000000'>" & LCase(overallStatus) & "</font></dt></td><td align='center'><dt>" & Environment.Value("TestCaseExecutionDate_Start") & " " & Environment.Value("TestCaseExecutionTime_Start") & "</dt></td><td align='center'><dt>" & secToMinSecConvert(DateDiff("s",Environment.Value("TestCaseExecutionTime_Start"), Time)) & "</dt></td><td align='center'><dt>" & Environment.Value("mExecutedAmount") & "</dt></td></tr>"&vbCrLf&_
""

' Keep first TSR's test case opened (on HTML via onload)
tsrContent = Replace(tsrContent, "</HEAD><BODY leftmargin", "</HEAD><BODY onload=javascript&colon;funcNavigate('"& ReportRelativePath &"'); leftmargin")

' Write updated content to the file
FileWriteContent Environment("tsrFilePath"), tsrContent

End Function


' ################## REPORT RECORDS ADDING #####################
' enterReport
'
' Description:
' This public function creates reports
'
' Parameters:
' Input:
' ReportType
' - NewComponentExecution
' - Recovery_Error
' - InformativeReport
' - RegularTextReport
' - ElapsedTime
' ReportStatus
' ReportText
'
'#######################################################

Function enterReport (ReportType, ReportStatus, ReportText)

Select Case ReportType
Case "NewComponentExecution"
Print "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
Print "MODULE '"&Environment.Value("DataTableSheetName")&"' EXECUTED."

Environment("reportContent") = Environment("reportContent")&vbCrLf&_
"<table cellspacing=1 cellpadding=1 width='660' bgcolor='#FFFFFF'><tr bgcolor='#dedede'><td colspan='2'>"&vbCrLf&_
"<TABLE onMouseOver=javascript&colon;moduleHeaderLightsUp(this); onMouseOut=javascript&colon;moduleHeaderLightsDown(this); onclick=javascript&colon;showHide('mod"&Environment.Value("mExecutedAmount")&"'); cellspacing=1 cellpadding=1 width='660' bgcolor='#CCCCCC'><TR>"&vbCrLf&_
"<TD width='20'><img src='icon\modResult_incomplete.png'></TD>"&vbCrLf&_
"<TD><dt>&nbsp;<strong><font color='#000000'>["&Environment.Value("ChainCallRow")&"] "&ReportText&"</font></strong></dt></strong></TD><TD align='center' width='120' bgcolor='#dedede'><dt>data row: <strong><font color='#000000'>" & Environment.Value("ChainRow") & "</font></strong>.</dt></strong></TD><TD align='center' width='160' bgcolor='#efefef'><dt>execution time: <strong><font color='#000000'>[not finished]</font></b></strong></TD></TR></TABLE></td></tr>"&vbCrLf&_
"</table><TABLE id='mod"&Environment.Value("mExecutedAmount")&"' style='display:none' cellspacing=1 cellpadding=1 width='660' bgcolor='#ffffff'>"

Case "dt"
StatusColor = "#555500"
LineColor = "#cccc00"
Environment("reportContent") = Environment("reportContent")&vbCrLf&_
"<tr><td align='center' valign='middle' width='68' bgcolor='"&StatusColor&"'><dt><font color='#ffffff'><strong>SAVE DATA</strong></font></dt></td><td bgcolor='"&LineColor&"' width='560'><dt>&nbsp;"&ReportText&"</dt></td></tr>"
Print "INFO: "&ReportText

Case "InformativeReport"
StatusColor = "#00688B"
LineColor = "#B0E2FF"
Environment("reportContent") = Environment("reportContent")&vbCrLf&_
"<tr><td align='center' valign='middle' width='68' bgcolor='"&StatusColor&"'><dt><font color='#ffffff'><strong>INFO</strong></font></dt></td><td bgcolor='"&LineColor&"' width='560'><dt>&nbsp;"&ReportText&"</dt></td></tr>"
Print "INFO: "&ReportText

Case "SnapShot"
Environment("reportContent") = Environment("reportContent")&vbCrLf&_
"<tr><td align='center' valign='middle' width='68' bgcolor='#efefef'><dt><font color='#444444'><strong>SNAPSHOT</strong></font></dt></td><td bgcolor='#efefef' width='560'><table cellspacing=1 cellpadding=1><tr><td align='center' width='100'><a href='"& ReportText &"' target='_blank'><img src='"& ReportText &"' height='80' width='80' alt='"& ReportStatus &"'></a></td><td><dt>Application / object <strong>" & ReportStatus & "</strong> was detected and snapshot made.</dt></td></tr></table></td></tr>"
Print "INFO: "&ReportText


Case "Recovery"
StatusColor = "#000000"
LineColor = "#333333"
Environment("reportContent") = Environment("reportContent")&vbCrLf&_
"<tr><td align='center' valign='middle' width='68' bgcolor='"& StatusColor &"'><dt><font color='#ffffff'><strong>RECOVERY</strong></font></dt></td><td bgcolor='"&LineColor&"' width='560'><dt><font color='ffffff'>&nbsp;"&ReportText&"</font></dt></td></tr>"
Print "INFO: "&ReportText

Case "testExecutionStop"
StatusColor = "#aa0000"
LineColor = "#ffcccc"
Environment("OverallStatus") = "failed"
Environment.Value("moduleResult") = "modResult_failed"
Environment("OverallStatusColor") = "#FFCCCC"
Environment("reportContent") = Environment("reportContent")&vbCrLf&_
"<tr><td align='center' valign='middle' width='68' bgcolor='"&StatusColor&"'><dt><font color='ffffff'><strong>CRITICAL</strong></font></dt></td><td bgcolor='"&LineColor&"' width='560'><dt>&nbsp;"&ReportText&" Test run terminated.</dt></td></tr>"&vbCrLf&_
"<tr bgcolor='red'><td colspan='2'><dt><font color='#ffffff'><strong>&nbsp;TEST EXECUTION STOPPED DUE ENCOUNTERED ERROR !</strong></font></dt></td></tr>"&vbCrLf
snapShot ' Perform Snapshot
' Environment("reportContent") = Environment("reportContent")&vbCrLf&_
' "<tr height='5'><td bgcolor='#dedede' colspan='2'></td></tr></table></table>"&vbCrLf
Print "CRITICAL: "&ReportText
Print "TEST EXECUTION STOPPED DUE ENCOUNTERED ERROR !"


Case "RegularTextReport"
If UCase(ReportStatus) = "PASSED" Then
StatusColor = "#009900"
LineColor = "#ccffcc"
ElseIf UCase(ReportStatus) = "WARNING" Then
StatusColor = "#FFA212"
LineColor = "#FFF38A"
ReportStatus = "WARNING"
If Environment("OverallStatus") <> "failed" Then
Environment("OverallStatus") = "warning"
Environment.Value("moduleResult") = "modResult_warning"
Environment("OverallStatusColor") = "#FFFCCC"
End If
Else
StatusColor = "#aa0000"
LineColor = "#ffcccc"
ReportStatus = "FAILED"
Environment("OverallStatus") = "failed"
Environment.Value("moduleResult") = "modResult_failed"
Environment("OverallStatusColor") = "#FFCCCC"
snapShot ' Perform Snapshot
End If

Environment("reportContent") = Environment("reportContent")&vbCrLf&_
"<tr><td align='center' valign='middle' width='68' bgcolor='"&StatusColor&"'><dt><font color='ffffff'><strong>"&UCase(ReportStatus)&"</strong></font></dt></td><td bgcolor='"&LineColor&"' width='560'><dt>&nbsp;"&ReportText&"</dt></td></tr>"
Print "CHECK: <"&ReportStatus&">. DETAILS: "&ReportText

Case "ElapsedTime"
Environment("tcElapsedTime") = DateDiff("s",Environment.Value("TestExecutionTime_Start"), Time)
Environment("reportContent") = replace(Environment("reportContent"), "[not finished]</font>", Environment("tcElapsedTime") & "</font></strong> sec.")
Environment("reportContent") = replace(Environment("reportContent"), "modResult_incomplete", Environment.Value("moduleResult"))

If Environment.Value("moduleResult") <> "modResult_passed" Then
Environment("reportContent") = replace(Environment("reportContent"), "<TABLE id='mod"&Environment.Value("ChainCallRow")&"' style='display:none'", "<TABLE id='mod"&Environment.Value("ChainCallRow")&"'")
End If

Environment("reportContent") = Environment("reportContent")&vbCrLf&_
"<tr height='5'><td bgcolor='#dedede' colspan='2'></td></tr></table></table>"
Environment.Value("TestExecutionTime_Start") = Time
End Select

' Update detailed test case report
tcReportUpdate Environment("ReportFolderPath")

End Function

 

' #######################################################
' generalReport

' Description:
' This function generates General Report into Execution Report according to
'
' Parameters:
' Input:
'
'
'
' #######################################################

Function generalReport (expectedValue, foundValue, comparisonExpectedResult, reportText)
If comparisonExpectedResult = true Then
reportMatchText = "Values should match"
Else
reportMatchText = "Values should NOT match"
End If


If (expectedValue = foundValue) = comparisonExpectedResult Then
enterReport "RegularTextReport", "passed", "<strong>" & reportText & "</strong>. Comparison settings: <strong>" & reportMatchText & "</strong>.<br>(expected: <strong>"& expectedValue & "</strong> / found: <strong>" & foundValue & "</strong>)"
GeneralReport = True
Else
enterReport "RegularTextReport", "failed", "<strong>" & reportText & "</strong>. Comparison settings: <strong>" & reportMatchText & "</strong>.<br>(expected: <strong>"& expectedValue & "</strong> / found: <strong>" & foundValue & "</strong>)"
GeneralReport = False
End If
End Function

' #######################################################
' snapShot
'
' Description:
' this function performs snapshot of all detected objects
' #######################################################

Function snapShot ()

' here add snapshot application(s) or object(s) using following pattern (uncomment and edit):

' I. CAB snapshot attempt
Set snapShotObj1 = SwfWindow("swfname:=CABMDIParent")
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If snapShotObj1.Exist ([0])Then
' Create SnapShot filename
myApplicationSnapShotFileName = "cabApp" & Year(Now)&"_"&Right("0"&Month(Now),2)&"_"&Right("0"&Day(Now),2)&"_"&Right("0"&Hour(Now),2)&"_"&Right("0"&Minute(Now),2)&"_"&Right("0"&Second(Now),2)&".png"

' Do SnapShot (the same folder as html report file!!)
snapShotObj1.CaptureBitmap Environment("ReportFolderPath")&"\"& myApplicationSnapShotFileName,True

' Enter SnapShot record into test report
EnterReport "SnapShot", snapShotObj1.ToString, myApplicationSnapShotFileName

End If

' II. CM snapshot attempt
Set snapShotObj2 = Browser("title:=CONTACT MANAGER").Page("title:=CONTACT MANAGER")
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If snapShotObj2.Exist ([0])Then
' Create SnapShot filename
myApplicationSnapShotFileName = "cmApp" & Year(Now)&"_"&Right("0"&Month(Now),2)&"_"&Right("0"&Day(Now),2)&"_"&Right("0"&Hour(Now),2)&"_"&Right("0"&Minute(Now),2)&"_"&Right("0"&Second(Now),2)&".png"

' Do SnapShot (the same folder as html report file!!)
snapShotObj2.CaptureBitmap Environment("ReportFolderPath")&"\"& myApplicationSnapShotFileName,True

' Enter SnapShot record into test report
EnterReport "SnapShot", snapShotObj2.ToString, myApplicationSnapShotFileName

End If


' III. ComC snapshot attempt
Set snapShotObj3 = SwfWindow("swfname:=frmComC_MDI")
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If snapShotObj3.Exist ([0])Then
' Create SnapShot filename
myApplicationSnapShotFileName = "comcApp" & Year(Now)&"_"&Right("0"&Month(Now),2)&"_"&Right("0"&Day(Now),2)&"_"&Right("0"&Hour(Now),2)&"_"&Right("0"&Minute(Now),2)&"_"&Right("0"&Second(Now),2)&".png"

' Do SnapShot (the same folder as html report file!!)
snapShotObj3.CaptureBitmap Environment("ReportFolderPath")&"\"& myApplicationSnapShotFileName,True

' Enter SnapShot record into test report
EnterReport "SnapShot", snapShotObj3.ToString, myApplicationSnapShotFileName

End If


' IV. Online snapshot attempt
Set snapShotObj4 = Browser("opentitle:=Authentication").Page("title:=home")
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If snapShotObj4.Exist ([0])Then
' Create SnapShot filename
myApplicationSnapShotFileName = "onlineApp" & Year(Now)&"_"&Right("0"&Month(Now),2)&"_"&Right("0"&Day(Now),2)&"_"&Right("0"&Hour(Now),2)&"_"&Right("0"&Minute(Now),2)&"_"&Right("0"&Second(Now),2)&".png"

' Do SnapShot (the same folder as html report file!!)
snapShotObj4.CaptureBitmap Environment("ReportFolderPath")&"\"& myApplicationSnapShotFileName,True

' Enter SnapShot record into test report
EnterReport "SnapShot", snapShotObj4.ToString, myApplicationSnapShotFileName

End If


' V. CaCe snapshot attempt
Set snapShotObj5 = Browser("title:=CaCe").Page("title:=CaCe")
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If snapShotObj5.Exist ([0])Then
' Create SnapShot filename
myApplicationSnapShotFileName = "onlineApp" & Year(Now)&"_"&Right("0"&Month(Now),2)&"_"&Right("0"&Day(Now),2)&"_"&Right("0"&Hour(Now),2)&"_"&Right("0"&Minute(Now),2)&"_"&Right("0"&Second(Now),2)&".png"

' Do SnapShot (the same folder as html report file!!)
snapShotObj5.CaptureBitmap Environment("ReportFolderPath")&"\"& myApplicationSnapShotFileName,True

' Enter SnapShot record into test report
EnterReport "SnapShot", snapShotObj5.ToString, myApplicationSnapShotFileName

End If

End Function

' #######################################################
' snapShotSpecific
'
' Description:
' this function performs snapshot of defined object
' #######################################################

Function snapShotSpecific (snapshotObject)

 

' I. myApplication1 snapshot attempt
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If snapshotObject.Exist ([0])Then
' Create SnapShot filename
myApplicationSnapShotFileName = "snapShotObject" & Year(Now)&"_"&Right("0"&Month(Now),2)&"_"&Right("0"&Day(Now),2)&"_"&Right("0"&Hour(Now),2)&"_"&Right("0"&Minute(Now),2)&"_"&Right("0"&Second(Now),2)&".png"

' Do SnapShot (the same folder as html report file!!)
snapshotObject.CaptureBitmap Environment("ReportFolderPath")&"\"& myApplicationSnapShotFileName,True

' Enter SnapShot record into test report
enterReport "SnapShot", snapshotObject.ToString, myApplicationSnapShotFileName

Else

' enterReport "RegularTextReport", "failed", snapshotObject & " was not detected and therefore snapshot was impossible to make."

End If


End Function

 

'################## REPORT SUPPORT FUNCTIONS #####################
' secToMinSecConvert
'
' Description:
' This public function calculates total hours, minutes and seconds and returs results in HH:MM:SS format (hours:minutes:seconds)
'
' Parameters:
' Input:

'
'#######################################################

Function secToMinSecConvert (TimeDifferenceInSeconds)

Hrs = Int(TimeDifferenceInSeconds/3600)
Min = Int((TimeDifferenceInSeconds - Hrs*3600)/60)
Sec = TimeDifferenceInSeconds - Hrs*3600 - Min*60

secToMinSecConvert = Right("00"&Hrs,2)&":"&Right("00"&Min,2)&":"&Right("00"&Sec,2)

End Function


Function fQCStatusUpdate()
vQCFlag=0
If vStepNo <> "" Then
vStep = Split(vStepNo,",")
flag =1
Else
flag =0
End If

If flag=1 Then
Set myrun = QCUtil.CurrentRun
If Not myrun is Nothing Then
Set runStepF = myrun.StepFactory
Set lst = runStepF.NewList("")
iCntVal = lst.Count

For jVal=0 to Ubound(vStep)
For iVal = 1 To iCntVal
If Trim(lst.Item(iVal).Field("ST_STEP_NAME")) = Trim(vStep(jVal)) Then
If Environment.Value("moduleResult") <> "modResult_passed" Then
lst.Item(iVal).Field("ST_ACTUAL") = "Not as expected"
lst.Item(iVal).Field("ST_STATUS") = "FAILED"
Else
lst.Item(iVal).Field("ST_ACTUAL") = "As expected"
lst.Item(iVal).Field("ST_STATUS") = "PASSED"
End If
lst.Post
vQCFlag=1
End If
Next
Next
End If
End If
End Function

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.