18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Report generation for Sahi Scripts in HTML

ravillaravilla Members
edited November -1 in Sahi - Open Source
Hello All,

Does Sahi supports this commands (WriteResult() and WriteHeading())


Top generate the final treport in HTML format ealier in QARUN(compuware) tool I used to use the below format.

In Sahi also also I need to generate the final report in HTML format .Can any one help.

=====================================================================

============================================================================================================================
;
Function InitialiseReports(SzRes, Szloc)
;
szPath=readini(szETipsIniFile,"Path","Default","")
;
TodayDate=FormatDate("DD-MM-YYYY")
szPath=readini(szETipsIniFile,"Path","Default","")
CurrentTime=FormatDate("hh-mm")
szResultsDirectory = szPath + "\RESULT" + TodayDate +"-"+ CurrentTime
MakeDir(szResultsDirectory)
MakeDir(szResultsDirectory + "\ScreenShots")

szReportFile = szResultsDirectory + "\" + SzRes + "-" + TodayDate + CurrentTime + ".html"
;szReportFile = szResultsDirectory + "\" + TodayDate + CurrentTime + ".html"
szReportList = szResultsDirectory + "\ReportList.txt"
szReportPage = szResultsDirectory + "\ReportPage.html"
;
create(szReportFile)
;
//For later reference of location to write html page.
writeini(szInifile,"ResultsDirectory","Location",szResultsDirectory)
writeini(szETipsIniFile,"ReportFile","Location",szReportFile)
writeini(szETipsIniFile,"ReportList","Location",szReportList)
writeini(szETipsIniFile,"ReportPage","Location",szReportPage)
;
ret = Open( szReportList , 'readwrite' )

;CreateReportPage()
WriteLine( szReportList , szReportFile )

WriteLine( szReportFile,"<table width=100% border=""0"" cellspacing=""1"" cellpadding=""1"">")
WriteLine( szReportFile, "<tr >")
WriteLine( szReportFile, "<td width=10%><img src=" + szPath + "\images\lsm.bmp></td>")
WriteLine( szReportFile, "<td align=center><font size=6>Automation Test results for "+ SzRes + "</font></td>")
WriteLine( szReportFile, "<td width=10%><img src=" + szPath + "\images\arrk.bmp></td>")
WriteLine( szReportFile,"<table width=100% border=""2"" cellspacing=""2"" cellpadding=""2"">")
WriteLine( szReportFile, "<tr>")
WriteLine( szReportFile, "<td width=30% bgcolor= CCCCCC><b> Application </b></td>")
WriteLine( szReportFile, "<td bgcolor=CCCCCC> eTips </td>")
WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile, "<tr>")
WriteLine( szReportFile, "<td width=30% bgcolor= CCCCCC><b> Tester </b> </td>")
WriteLine( szReportFile, "<td bgcolor=CCCCCC> " + ETIPS_Tester +"</td>")
WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile, "<tr>")
WriteLine( szReportFile, "<td width=30% bgcolor= CCCCCC> <b> Location </b></td>")
WriteLine( szReportFile, "<td bgcolor=CCCCCC>" + ETIPS_Test_Location +"</td>")
WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile, "<tr>")
WriteLine( szReportFile, "<td width=30% bgcolor= CCCCCC> <b> Contact Details </b> </td>")
WriteLine( szReportFile, "<td bgcolor=CCCCCC> " + ETIPS_Tester_contact +"</td>")
WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile, "<tr>")
WriteLine( szReportFile, "<td width=30% bgcolor= CCCCCC><b> Date & Time </b> </td>")
WriteLine( szReportFile, "<td bgcolor=CCCCCC> " + TodayDate + " : " + CurrentTime +"</td>")
WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile, "<tr>")
WriteLine( szReportFile, "<td width=30% bgcolor= CCCCCC><b> Test Reference </b> </td>")
WriteLine( szReportFile, "<td bgcolor=CCCCCC> " + Szloc +"</td>")
WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile,"</table>")
WriteLine( szReportFile, "<br> </br> ")
;
End Function ;InitialiseReports()
;
;
;
Function WriteResult(SzDet,szDescription,szTestData,szRef,szStatus )
;
//Directory settings in .ini file are set by the InitialiseReport script at the beginning of batch run
//HTML Page
szReportFile = readini(szETipsIniFile,"ReportFile","Location","")
szReportList = readini(szETipsIniFile,"ReportList","Location","")
szPath = readini(szETipsIniFile,"Path","Default","")
;
ret = Open( szReportFile , 'write' )
;
;szStatus=str(szStatus)
;

switch szStatus
case 0
usercheck(szDescription,0,szDescription)
;

WriteLine( szReportFile,"<table align = center width=100% border=""1"" cellspacing=""1"" cellpadding=""1"">")
WriteLine( szReportFile, "<tr>")
WriteLine( szReportFile, "<td width=15% ><font color=red>" + SzDet +"</font></td>")
WriteLine( szReportFile, "<td ><font color=red>" + szDescription + "</font></td>")
WriteLine( szReportFile, "<td width=7% ><font color=red>Fail</font></td>")
WriteLine( szReportFile, "<td width=25% ><font color=red>" + szTestData + "</font></td>")
WriteLine( szReportFile, "<td width=15% ><font color=red>" + szRef+ "</font></td>")
WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile,"</table>")
case 1
usercheck(szDescription,1,szDescription)
;

WriteLine( szReportFile,"<table align = center width=100% border=""1"" cellspacing=""1"" cellpadding=""1"">")
WriteLine( szReportFile, "<tr> ")
WriteLine( szReportFile, "<td width=15% ><font color=green>"+ SzDet +"</font></td>")
WriteLine( szReportFile, "<td ><font color=green>" + szDescription + "</font></td>")
WriteLine( szReportFile, "<td width=7% ><font color=green>Pass</font></td>")
WriteLine( szReportFile, "<td width=25% ><font color=green>" + szTestData + "</font></td>")
WriteLine( szReportFile, "<td width=15% ><font color=green>" + szRef+ "</font></td>")

WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile,"</table>")
case "name"
//writing title of script the HTML page

WriteLine( szReportFile, "<p>")
WriteLine( szReportFile, "<a name=" + szDescription + "></a>")
WriteLine( szReportFile, "Test Script: - <big>" + szDescription + "</big>")
WriteLine( szReportFile, "</p>")
;
//Writing title of script to the text report list
ret = Open( szReportList , 'write' )
WriteLine(szReportList, szDescription)
ret = close(szReportList)
case "testvalue"
if (szDescription = 1)

WriteLine( szReportFile, "<p>")
;WriteLine( szReportFile, "Overall Result: - <big>Pass</big> <img src=" + szPath + "\images\pass.bmp>")
WriteLine( szReportFile, "<td width=25% >Overall Result: - " + SzDet + " </td>")
WriteLine( szReportFile, "</p>")
;
ret = Open( szReportList , 'write' )
WriteLine(szReportList, "pass")
ret = close(szReportList)
endif
if (szDescription = 0)

WriteLine( szReportFile, "<p>")
;WriteLine( szReportFile, "Overall Result: - <big>Fail</big> <img src=" + szPath + "\images\fail.bmp>")
WriteLine( szReportFile, "<td width=25% >Overall Result: - <big>"+ SzDet +"</big></td>")
WriteLine( szReportFile, "</p>")
;
ret = Open( szReportList , 'write' )
WriteLine(szReportList, "fail")
ret = close(szReportList)
endif
if (szDescription = -1)

WriteLine( szReportFile, "<p>")
;WriteLine( szReportFile, "Overall Result: - <big>Check failed</big> <img src=" + szPath + "\images\fail.bmp>")
WriteLine( szReportFile, "<td width=25% >Overall Result: - <big>"+ SzDet +"</big></td>")
WriteLine( szReportFile, "</p>")
;
ret = Open( szReportList , 'write' )
WriteLine(szReportList, "fail")
ret = close(szReportList)
endif
if (szDescription = -2)

WriteLine( szReportFile, "<p>")
;WriteLine( szReportFile, "Overall Result: - <big>Runtime error occurred in the script</big> <img src=" + szPath + "\images\fail.bmp>")
WriteLine( szReportFile, "<td width=25% >Overall Result: - <big>Runtime error occurred in the script</big></td>")
WriteLine( szReportFile, "</p>")
;
ret = Open( szReportList , 'write' )
WriteLine(szReportList, "fail")
ret = close(szReportList)
endif
case "screenshot"

WriteLine( szReportFile,"<table width=100% border=""1"" cellspacing=""1"" cellpadding=""1"">")
WriteLine( szReportFile, "<tr>")
WriteLine( szReportFile, "<td width=25%><img src=" + szPath + "\images\photo.bmp></td>")
WriteLine( szReportFile, "<td><a href=""" + szDescription + """>" + szDescription + "</a></td>")
WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile,"</table>")
default

WriteLine( szReportFile,"<table width=100% border=""1"" cellspacing=""1"" cellpadding=""1"">")
WriteLine( szReportFile, "<tr>")
WriteLine( szReportFile, "<td width=25%><img src=" + szPath + "\images\note.bmp></td>")
WriteLine( szReportFile, "<td>" + szDescription + "</td>")
WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile,"</table>")
;
logcomment(szDescription)
end switch
;
close(szReportFile)

End Function ;WriteResult()
;
;===========================================================================================================================
;
Function WriteHeading()
;
//Directory settings in .ini file are set by the InitialiseReport script at the beginning of batch run
//HTML Page
szReportFile = readini(szETipsIniFile,"ReportFile","Location","")
szReportList = readini(szETipsIniFile,"ReportList","Location","")
szPath = readini(szETipsIniFile,"Path","Default","")
;
ret = Open( szReportFile , 'write' )
WriteLine( szReportFile,"<table align = center width=100% border=""1"" cellspacing=""1"" cellpadding=""1"">")
WriteLine( szReportFile, "<tr>")
WriteLine( szReportFile, "<td width=15% bgcolor=CCCCC ><font color=Black><b>Page </b></font></td>")
WriteLine( szReportFile, "<td bgcolor=CCCCC ><font color=Black><b> Description </b></font></td>")
WriteLine( szReportFile, "<td width=7% bgcolor=CCCCC ><font color=Black><b>Result</b></font></td>")
WriteLine( szReportFile, "<td width=25% bgcolor=CCCCC ><font color=Black><b>Test data</b></font></td>")
WriteLine( szReportFile, "<td width=15% bgcolor=CCCCC ><font color=Black><b>Test Case Ref</b></font></td>")
WriteLine( szReportFile, "</tr>")
WriteLine( szReportFile,"</table>")
End Function ;Write Heading()
;



Function Main


;WriteResult(0,cmdline(1),"name" ) ; Writes Script Name to HTML file
szTestDataRow = 2

; Setup IE & Read input file

Setup()

GetClientDetails(szTestDataRow) ; Read input file

EnterClientCodeDetails(szCode1,szDesc1,szNomCode1,szNomDesc1,"","","",szNomCode1)

EnterClientCodeDetails(szCode2,szDesc2,szNomCode2,szNomDesc2,"","",szNomCode2,"")

EnterClientCodeDetails(szCode3,szDesc3,szNomCode3,szNomDesc3,"",szNomCode3,"","")

EnterClientCodeDetails(szCode4,szDesc4,szNomCode4,szNomDesc4,szNomCode4,"","","")

LogOffEtips()
CloseAllInternetExplorers()
Sign In or Register to comment.