There are at least a dozen and a half discussions around overriding Reporter.ReportEvent. However, I'm interested in knowing whether anyone here ever tried to add additional functionality to Reporter.ReportEvent.
The goal is to add complimentary code to the existing function so that when a user calls the method, both the default and the custom functionality are exercised.
One thought is that I could achieve this by overriding the method; however, the default functionality would be eliminated if precautions towards retention aren't taken.
So with that in mind, does anyone know where I can look to find the original code for this method?
I remember seeing Tarun write about this in his book about "So I thought that I knew QTP". Sorry if the Title is not exact. He was writing about overwriting the properties of Reporter.ReportEvent. It may be a good place to look
Let's see if he chimes in on this post. I've seen plenty of code examples on how to override the function, but would love to see how to override it and retain its original functionality. I should have realized this earlier, but the original code may not be a viable cut n' paste job because the target method is wrapped up in QTP's class libraries. But if I could find the equivalent (which as you suggest, may be in Tarun's book), then that could work too.
Thanks Kevin!
Last edited by CWFTESTY; 12-13-2013 at 04:52 AM.
Reason: Thankyou!
Call REP_Footer()
ts.close()
If DEBUG_MODE Then ' Only produce in debug mode, no need to when running in unattended mode
Set objIE = CreateObject("InternetExplorer.Application")
objIE.visible = True
objIE.Navigate REP_FILE_URL
End If
' *----------------------------------------------*
' * Description: Wrapper for a passed check *
' * Author: Mark Smith *
' * Date 28-May-2015 *
' *----------------------------------------------*
Sub REP_PASS(iBrowser, sFileName, sLogStep, sLogMessage)
' *-------------------------------------------------*
' * Description: Wrapper for a non-fatal Warning *
' * Author: Mark Smith *
' * Date 28-May-2015 *
' *-------------------------------------------------*
Sub REP_WARNING(iBrowser, sFileName, sLogStep, sLogMessage)
' *----------------------------------------------*
' * Description: Wrapper for a Failed check *
' * Author: Mark Smith *
' * Date 28-May-2015 *
' *----------------------------------------------*
Sub REP_FAIL(iBrowser, sFileName, sLogStep, sLogMessage)
sFileName = sFileName & MISC_DateTime(Now)
LOG_ScreenShot iBrowser, sFileName
Call REP_AddNewLine(REP_STEP, sLogStep, sLogMessage, sFileName, "Fail")
REP_STEP = REP_STEP + 1
' Produce run summary if its the last iteration
If Cint(Environment("TestIteration")) = Cint(DataTable.GetRowCount) Then
Call REP_CloseFile
End If
If STOP_RUN Then
MISC_TidyUp
Else
With Browser("CreationTime:=0").Page("micClass:=Page")
.Image("file name:=ccflcb.gif").Click
.Sync
End With
ExitActionIteration
End If
End Sub
' *----------------------------------------------*
' * Description: Wrapper to write info to *
' * the log e.g. Proposal ID *
' * Author: Mark Smith *
' * Date 28-May-2015 *
' *----------------------------------------------*
Sub REP_INFO(iBrowser, sFileName, sLogStep, sLogMessage)
' *----------------------------------------------*
' * Description: Log to the script log report *
' * Author: Mark Smith *
' * Date 27-May-2015 *
' *----------------------------------------------*
Sub LOG_WriteLog(slogStep, slogMessage)
' Create FSO object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Set the filename
fName = TEST_EVIDENCE_FOLDER & THIS_APP & Chr(92) & Environment("TestName") & Chr(92) & Environment("TestName") & "_Log.txt"
' Check first time in
If Not RESULTS_LOG_EXISTS Then
' If the file already exists delete it
If objFSO.FileExists(fName) Then
objFSO.DeleteFile fName, False
End If
Set objFile = objFSO.CreateTextFile(fName, ForWriting)
RESULTS_LOG_EXISTS = True
Else
Set objFile = objFSO.OpenTextFile(fName,8)
End If
' *---------------------------------------------------------*
' * Description: Take a screenshot of the passed browser *
' * and save it to the passed directory and *
' * name. *
' * Author: Mark Smith *
' * Date 27-May-2015 *
' *---------------------------------------------------------*
Sub LOG_ScreenShot(iBrowser, sFileName)
' Have to wait here as quick running scripts can
' try to save 2 images with the same name/timestamp
' which generates a 'file already exists' error
Wait(1)
If Browser("CreationTime:="&iBrowser).Exist(1) Then
Browser("CreationTime:="&iBrowser).CaptureBitmap TEST_EVIDENCE_FOLDER & THIS_APP & Chr(92) & Environment("TestName") & Chr(92) & _
REP_DIR & Chr(92) & sFileName & ".png"
End If
I'll try it but I'm in a bind - the client wants the report looking like the attachment - which means I need to add info to the log file that gets used to create the xml - then modify the xsl and css to get soemthing close to the report.
Don't know where the log file is held nor do I know how to add to it.
jloyzaga,
I took a look at your attachment.
I have done something similar with MS Word.
You can look at Tarun's books where he discusses communicating with MS Word. Also he has information regarding how to write to a PDF file. In either case you create an object to the application such as Word or PDF. Then you create a file object. You make table objects and then add them to the file object. It is tedious. You can use some logic from mwsrosso but you would have to practice experimenting on your own. Another difficulty is that UFT uses VBScript and PDF files use VBA which are about 75% the same. If you have time to spend it can be a great learning experience and even fun. I worked on this with Word for a couple of weeks and got it to make a nice table with human readable output which users liked a lot more than UFT output.
Thanks,
Kevin
When in Florida, Don't Tampa with the code. I made this up.