Micro Focus QTP (UFT) Forums
Customized HTML reports in QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Customized HTML reports in QTP (/Thread-Customized-HTML-reports-in-QTP)

Pages: 1 2


Customized HTML reports in QTP - azeem - 04-08-2010

HI All,

I am planning to write reports in HTML as per the client request, he wants to see only results in a table and result should be either pass or fail.

Could you please help me in understanding the concept of Customized HTML reports in QTP, I was able to create table structure in HTML, but not sure where to embedd this code in QTP script or should I invoke any VBS file, Please help me with sample code "Highly Appreciable"

Thanks for your precious time and knowledge sharing...!!!

Thanks,
Azeem


RE: Customized HTML reports in QTP - rdemers25 - 05-28-2010

When I used in TestPartner, what I did was I logged the information to a log file, then when the script was done, I converted that code to HTML. You could probably do the same thing in QTP.


RE: Customized HTML reports in QTP - funajju - 05-28-2010

HI Azeem ,

I dont know whether it helps u or not.
But one thing In QTP Test Results window you can find VIew>> filter option >> where u can select checkboxes which are only pass or fail etc. & then go to File>> Export to HTML to ur Specific location.You can get the reports right


RE: Customized HTML reports in QTP - basanth27 - 05-31-2010

Load your functions to the vbs and then execute it on qtp. or primitively you can just paste the code on qtp and execute it. Ultimately either way you should see the results on html.


RE: Customized HTML reports in QTP - carr2805 - 07-07-2010

hello,

I have one question, after the test performed in case of error in the result
appears that the object has an error, the reason and parameter.

How to export it to excel in the case?

thanks

Mark


RE: Customized HTML reports in QTP - Arun Prakash - 07-10-2010

Hi Azeem,

We can use write function using HTML for the same.
Code:
Public Function fnSetResultLog()

    Dim objFileSystemObject, objTextFileObject
    Dim objTempFile, objFolder
    Dim sFileText
    Dim iPos

    'Creating a folder appended with date and time
      bFinalStatus=True
    tmStartTime=now
    
      Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")
    
    If  not objFileSystemObject.FolderExists(gsBasicFolder)Then
        Set objFolder=objFileSystemObject.createFolder(gsBasicFolder)
    End If
    
      Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")

      If not objFileSystemObject.FileExists(gsReportFile)  Then
        'Creation of HTML file and a temp file if it does not exist already
        Set objTextFileObject= objFileSystemObject.CreateTextFile(gsReportFile, True)
        Set objTempFile= objFileSystemObject.CreateTextFile(gsTempFile, True)

        'Write initial content of file
        objTextFileObject.WriteLine "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">"
        objTextFileObject.WriteLine "<HTML><BODY><CENTER>"
        objTextFileObject.WriteLine "<H1><FONT COLOR=#990000 face=""Arial"">Result Log</FONT></H1><BR>"

        objTextFileObject.WriteLine "<TABLE ALIGN=""Center"" BORDER=""1"" WIDTH=40% CELLPADDING=""1"" >"
        objTextFileObject.WriteLine "<TR BGCOLOR=""#CCCC99"">"
        objTextFileObject.WriteLine "<TD align=""left"" valign=""top""><FONT COLOR=#559999 face=""Arial""><small><B>Total Test Cases Passed: 0</B></small></FONT></TD>"
        objTextFileObject.WriteLine "</TR>"
        objTextFileObject.WriteLine "<TR BGCOLOR=""#CCCC99"">"
        objTextFileObject.WriteLine "<TD align=""left"" valign=""top""><FONT COLOR=#559999 face=""Arial""><small><B>Total Test Cases Failed: 0</B></small></FONT></TD>"
        objTextFileObject.WriteLine "</TR>"
        objTextFileObject.WriteLine "</TABLE>"
        objTextFileObject.WriteLine "<BR>"
    Else
        'Setting the position of the file if the file is already created
        Set objTextFileObject= objFileSystemObject.OpenTextFile(gsReportFile,1)
        sFileText=objTextFileObject.readall
        iPos=instr(1,sFileText,"<!--LOGDETAILS-->",vbTextCompare)
        If iPos > 0 Then
            sFileText=mid(sFileText,1,iPos-1)
            objTextFileObject.close
        End If
        
        Set objTextFileObject= objFileSystemObject.OpenTextFile(gsReportFile, 2)
        objTextFileObject.write sFileText
        
        Set objTempFile= objFileSystemObject.OpenTextFile(gsTempFile, 8)
    End If
'=============== writing to the main file =======================================================
Code:
objTextFileObject.WriteLine "<TABLE ALIGN=""Center"" BORDER=""0"" WIDTH=100% CELLPADDING=""1"" >"
    objTextFileObject.WriteLine "<TR BGCOLOR=""#aeaeff"">"            
    objTextFileObject.WriteLine "<TH width=15% rowspan=""1"" align=""left"" valign=""top""><FONT COLOR=black face=""Arial""><small><B><a href=""#" & now &  """>"  & gsTestCaseID & "</a></B></small></FONT></TH>"
    objTextFileObject.WriteLine "<TH width=85% colspan=""5"" align=""left"" valign=""center""><FONT COLOR=black face=""Arial""><small>" & gsTestCaseDesc &   "</small></FONT></TH>"
    objTextFileObject.WriteLine "</TR>"
    objTextFileObject.WriteLine "<TR BGCOLOR=""#aeaeff"">"                      
    objTextFileObject.WriteLine "<TH width=50% colspan=""2""align=""left"" valign=""center""><FONT COLOR=black face=""Arial""><small>Date: " & now & "</small></FONT></TH>"
    objTextFileObject.WriteLine "<TH width=35% colspan=""3""align=""left"" valign=""center""><FONT COLOR=black face=""Arial""><small><B>Duration:</B></small></FONT></TH>"
    objTextFileObject.WriteLine "<TH width=15% align=""left"" valign=""center""><FONT COLOR=black face=""Arial""><small><B>Status:</B></small></FONT></TH>"
    objTextFileObject.WriteLine "</TR>"
    objTextFileObject.Close

'=============== writing to the temp file =======================================================
Code:
objTempFile.WriteLine "<!--LOGDETAILS-->"
    objTempFile.WriteLine "<BR>"
    objTempFile.WriteLine "<TABLE ALIGN=""Center"" BORDER=""1"" WIDTH=100% CELLPADDING=""1"" >"
    objTempFile.WriteLine "<TR BGCOLOR=""#996600"">"            
    objTempFile.WriteLine "<TH width=15% rowspan=""1"" align=""left"" valign=""top""><FONT COLOR=white face=""Arial""><small><B><a name=""" & now & """>" & gsTestCaseID & "</a></B></small></FONT></TH>"  
    objTempFile.WriteLine "<TH width=85% colspan=""5"" align=""left"" valign=""bottom""><FONT COLOR=white face=""Arial""><small>" & gsTestCaseDesc &  "</small></FONT></TH>"
    objTempFile.WriteLine "</TR>"
    objTempFile.WriteLine "<TR BGCOLOR=""#996600"">"            '#CCCC99
    objTempFile.WriteLine "<TH width=50% colspan=""2""align=""left"" valign=""center""><FONT COLOR=white face=""Arial""><small>Date: " & now & "</small></FONT></TH>"
    objTempFile.WriteLine "<TH width=35% colspan=""3""align=""left"" valign=""center""><FONT COLOR=white face=""Arial""><small><B>Duration:</B></small></FONT></TH>"
    objTempFile.WriteLine "<TH width=15% align=""left"" valign=""center""><FONT COLOR=white face=""Arial""><small><B>Status:</B></small></FONT></TH>"
    objTempFile.WriteLine "</TR>"
    
    objTempFile.WriteLine "<TR bgColor=#996600>"
    
    objTempFile.WriteLine "<TH width=""80""colspan=""1"" ><FONT COLOR=#FF9933 face=""Arial""><small>Test Case ID</small></FONT></TH>"
    objTempFile.WriteLine "<TH width=""80""colspan=""1"" ><FONT COLOR=#FF9933 face=""Arial""><small>Request ID</small></FONT></TH>"
    
    objTempFile.WriteLine "<TH width=""80""colspan=""1"" ><FONT COLOR=#FF9933 face=""Arial""><small>Step to be Preformed</small></FONT></TH>"
    objTempFile.WriteLine "<TH width=""80""colspan=""1"" ><FONT COLOR=#FF9933 face=""Arial""><small>Status</small></FONT></TH>"
    objTempFile.WriteLine "<TH width=""80""colspan=""2"" ><FONT COLOR=#FF9933 face=""Arial""><small>Snap Shots</small></FONT></TH>"

      objTempFile.WriteLine "</TR>"    
      objTempFile.Close

    Reporter.reportEvent micDone,"Starting Test","Starting Execution of Test Case : " & gsTestCaseID

End Function
this is a sample script to set the result log


RE: Customized HTML reports in QTP - QTPScript - 08-29-2012

This Two Years old Post and still works for me.

I have question can we add Jquery in report ?


RE: Customized HTML reports in QTP - dfwweb - 02-26-2013

I am trying to understand the process of creating HTML Reports in QTP. So we have executed the testcases written in Excel and now trying to generate the report in HTML using QTP. Can some one please help out!

I want to know how to write in QTP the following
-Be able to read the data in Excel - all the testcases excuted and then generate report in HTML.


RE: Customized HTML reports in QTP - SureshVaratharajan - 06-17-2013

Hi,

How to use the above script for my project?


RE: Customized HTML reports in QTP - vinod123 - 06-22-2013

instead of using the script try this registry tweak
HKEY_LOCAL_MACHINE\Software\Mercury Interactive\QuickTest Professional\Logger\Media\Log and modify Active DWORD from 0 to 1 This will create a folder with name log it will save a html file for the report. This will save ur time