narasimha Posted February 27, 2014 Share Posted February 27, 2014 Hi All, I am new to Autoit Forum How to generate " HTML "report to each testcase as pass or fail based on successful or unsuccessful.Please suggest and guide me.If anyone has already implemented then can you share source code? Link to comment Share on other sites More sharing options...
Malkey Posted February 27, 2014 Share Posted February 27, 2014 Here is some source code for you to modify in order to make it as complicated as you can make it. Local $sFileName = "A_Report.html" Local $sReportText = "Report:-" & @CRLF & _ "Test 1/ Passed" & @CRLF & _ "Test 2/ Failed" & @CRLF & _ "Test 3/ Failed" ;ConsoleWrite( $sReportText & @LF) ; Un-comment this line and see output in Output window of SciTE. (Toggle "F8" key when in SciTE.) Local $sName = _HtmlReport($sFileName, $sReportText) ;ConsoleWrite($sName & @LF) ShellExecute($sName) ; Opens HTML file with default web browser. Func _HtmlReport($sFileName, $sReport) Local $Source = _ '<html>' & @CRLF & _ '<body>' & StringReplace($sReport, @LF, "<BR>") & _ '</body>' & @CRLF & _ '</html>' ;ConsoleWrite($Source & @LF) ; ----- Increment file name (No duplicate file names) ----- Local $iNum = 1 While FileExists($sFileName) Sleep(10) $sFileName = StringRegExpReplace($sFileName, "(?i)^([^\.]+?)(?:_?\d*)(\.html?)", "\1_") & $iNum & StringRegExpReplace($sFileName, "(?i)^([^\.]+?)(?:_?\d*)(\.html?)", "\2") $iNum += 1 WEnd ; -------> End of Increment file name ---------- FileWrite($sFileName, $Source) Return $sFileName EndFunc ;==>_HtmlReport Link to comment Share on other sites More sharing options...
mikell Posted February 27, 2014 Share Posted February 27, 2014 (edited) Malkey, sometimes you're really scary Local $sFileName = "A_Report" Local $sReportText = "Report:-" & @CRLF & _ "Test 1/ Passed" & @CRLF & _ "Test 2/ Failed" & @CRLF & _ "Test 3/ Failed" Local $sName = _HtmlReport($sFileName, $sReportText) ShellExecute($sName) Func _HtmlReport($sFileName, $sReport) Local $Source = _ '<html>' & @CRLF & _ '<body>' & StringReplace($sReport, @LF, "<BR>") & _ '</body>' & @CRLF & _ '</html>' Local $newfile = @scriptdir & "\" & $sFileName & ".html" Local $iNum = 1 While FileExists($newfile) $iNum += 1 $newfile = @scriptdir & "\" & $sFileName & " (" & $iNum & ").html" Wend FileWrite($newfile, $Source) Return $newfile EndFunc ;==>_HtmlReport Edited February 27, 2014 by mikell Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now