Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Customized HTML reports in QTP
#1
Not Solved
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
Reply
#2
Not Solved
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.
Reply
#3
Not Solved
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
Reply
#4
Not Solved
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.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#5
Not Solved
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
Reply
#6
Not Solved
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
Reply
#7
Not Solved
This Two Years old Post and still works for me.

I have question can we add Jquery in report ?
Reply
#8
Not Solved
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.
Reply
#9
Not Solved
Hi,

How to use the above script for my project?
Reply
#10
Not Solved
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [UFT] Get text into DIV through HTML tag robertosalemi 2 5,560 03-29-2016, 09:43 PM
Last Post: robertosalemi
  How to attach HTML file to Email Naresh 0 3,084 04-06-2015, 02:04 PM
Last Post: Naresh
  Reports shayk1985 3 4,070 01-03-2013, 10:11 PM
Last Post: diya
  How to generate QTP report in a new file(html)? yogesh kancherla 5 14,968 10-21-2012, 04:52 PM
Last Post: yogesh kancherla
  How to open html file and update values in particular cell of a table in QTP? yogesh kancherla 2 6,126 10-11-2012, 05:59 PM
Last Post: yogesh kancherla

Forum Jump:


Users browsing this thread: 1 Guest(s)