SPONSORS:






User Tag List

Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Member
    Join Date
    Nov 2009
    Posts
    52
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Complimenting Reporter.ReportEvent

    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?

    Thanks,
    -C-

  2. #2
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Kew Gardens, United States
    Posts
    2,650
    Post Thanks / Like
    Blog Entries
    1
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    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

    Thanks,

    Kevin

  3. #3
    Member
    Join Date
    Nov 2009
    Posts
    52
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    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!

  4. #4
    Advanced Member
    Join Date
    May 2007
    Posts
    612
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    Here's a link to where Tarun assisted someone else with the same issue... Overriding Reporter & Using the Default functionality
    Dennis Belew

  5. #5
    Member
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    359
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    this link does not work

  6. #6
    Moderator
    Join Date
    Sep 2001
    Location
    Doncaster, UK
    Posts
    5,811
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    I wrote my own reporting functions because I found the in-built reporting cumbersome and I could easily add new functionality.
    Mark Smith.

  7. #7
    Member
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    359
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    would you care to share?

  8. #8
    Moderator
    Join Date
    Sep 2001
    Location
    Doncaster, UK
    Posts
    5,811
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    Of course. You need to add a global variable:

    Const TEST_EVIDENCE_FOLDER = "C:\systems-testing\projects\Automation\UFT\Test Evidence"

    In your script you need to set the app ID

    ' Set the Application
    THIS_APP = "FPS"

    You then need to create a folder the same name as the script name:

    "C:\systems-testing\projects\Automation\UFT\Test Evidence\FPS\My Script Name"






    Here are the reporting functions

    ================================================== ================================================== =====
    Sub REP_IntitialiseReport

    ' Only do on First Iteration
    If NEW_REP Then
    REP_DIR = "REP_" & MISC_DateTime(Now)
    FULL_REP_DIR = TEST_EVIDENCE_FOLDER & THIS_APP & Chr(92) & Environment("TestName") & Chr(92) & REP_DIR
    sRepName = FULL_REP_DIR & Chr(92) & Environment("TestName") & ".html"
    REP_OpenFile(sRepName)
    REP_CreateHeader
    NEW_REP = False
    LAST_ITERATION = DataTable.GetRowCount
    End If

    REP_NewIteration

    End Sub

    Function REP_OpenFile(strFileName)

    REP_START_TIME = Time
    Set fso = CreateObject("Scripting.FileSystemObject")
    fso.CreateFolder FULL_REP_DIR
    Set ts = fso.OpenTextFile(strFileName, FOR_WRITING, True)
    REP_FILE_URL = strFileName

    End Function

    Function REP_CreateHeader()

    ts.WriteLine("<html>")
    ts.WriteLine("<title>Test Results</title>")
    ts.WriteLine("<head></head>")
    ts.WriteLine("<body>")
    ts.WriteLine("<hr>")
    ts.WriteLine("<table border='0' width='100%'>")
    ts.WriteLine("<tr><td bgcolor='#001BD4'><b><font color='#FFFFFF' face='Tahoma' size='6'>" & "Test Results For Script: " & Environment("TestName") & "</font></b></td>")

    End Function

    Function REP_NewIteration()

    ts.WriteLine("<tr><td width='100%' colspan='5' bgcolor='#009FDF'><b><font face='Tahoma' size='4' color='#FFFFFF'>Iteration Number: " & Environment("TestIteration") & " </font></b></td></tr>")
    ts.WriteLine("<table border='0' width='100%' height='47'>")
    ts.WriteLine("<tr>")
    ts.WriteLine("<td width='13%' bgcolor='#4d4dff' align='center'><b><font color='#FFFFFF' face='Tahoma' size='2'>Step</font></b></td>")
    ts.WriteLine("<td width='24%' bgcolor='#4d4dff'><b><font color='#FFFFFF' face='Tahoma' size='2'>Objective</font></b></td>")
    ts.WriteLine("<td width='23%' bgcolor='#4d4dff'><b><font color='#FFFFFF' face='Tahoma' size='2'>Result</font></b></td>")
    ts.WriteLine("<td width='22%' bgcolor='#4d4dff'><b><font color='#FFFFFF' face='Tahoma' size='2'>Screen Shot</font></b></td>")
    ts.WriteLine("<td width='18%' bgcolor='#4d4dff' align='center'><b><font color='#FFFFFF' face='Tahoma' size='2'>Pass/Fail</font></b></td>")
    If DEBUG_MODE Then
    Print "Iteration: " & Environment("TestIteration")
    End If

    End Function

    Function REP_AddNewLine(repStep, repCheck,repResult, repFileName, strPassFail)

    tmp = Replace(repFileName,".png","")
    linkText = Replace(tmp,"_"," ")

    ts.WriteLine("<tr>")
    ts.WriteLine("<td width='13%' bgcolor='#cce0ff' valign='middle' align='center'>" & repStep & "</td>")
    ts.WriteLine("<td width='13%' bgcolor='#cce0ff' valign='middle' align='justify'>" & repCheck & "</td>")
    ts.WriteLine("<td width='24%' bgcolor='#cce0ff' valign='top' align='justify'>" & repResult & "</td>")

    Select Case UCase(strPassFail)
    Case "PASS"
    ts.WriteLine("<td width='23%' bgcolor='#cce0ff' valign='top' align='justify'><a href=" & Chr(34) & repFileName & ".png" & Chr(34) & "target='_blank'>" & linkText & "</a></td>")
    ts.WriteLine("<td width='18%' bgcolor='#cce0ff' valign='middle' align='center'><b><font color='Green' face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")
    REP_NO_PASS = REP_NO_PASS + 1
    Case "FAIL"
    ts.WriteLine("<td width='23%' bgcolor='#cce0ff' valign='top' align='justify'><a href=" & Chr(34) & repFileName & ".png" & Chr(34) & "target='_blank'>" & linkText & "</a></td>")
    ts.WriteLine("<td width='18%' bgcolor='#cce0ff' valign='middle' align='center'><b><font color='Red' face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")
    REP_NO_FAIL = REP_NO_FAIL + 1
    Case "WARN"
    ts.WriteLine("<td width='23%' bgcolor='#cce0ff' valign='top' align='justify'><a href=" & Chr(34) & repFileName & ".png" & Chr(34) & "target='_blank'>" & linkText & "</a></td>")
    ts.WriteLine("<td width='18%' bgcolor='#cce0ff' valign='middle' align='center'><b><font color='Orange' face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")
    REP_NO_WARN = REP_NO_WARN + 1
    Case "INFO"
    ts.WriteLine("<td width='23%' bgcolor='#cce0ff' valign='top' align='justify'>" & linkText & "</a></td>")
    ts.WriteLine("<td width='18%' bgcolor='#cce0ff' valign='middle' align='center'><b><font color='Black' face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")
    REP_NO_INFO = REP_NO_INFO + 1
    End Select

    ts.WriteLine("</tr>")

    End Function

    Function REP_Footer()

    REP_END_TIME = Time
    ts.WriteLine("</table>")
    ts.WriteLine("<hr>")
    ts.WriteLine("<table border='0' width='50%'>")
    ts.WriteLine("<tr><td width='100%' colspan='2' bgcolor='#000000'><b><font face='Tahoma' size='2' color='#FFFFFF'>Summary</font></b></td></tr>")
    ts.WriteLine("<tr><td width='45%' bgcolor='#E8FFE8'><b><font face='Tahoma' size='2'>Total VPs Passed</font></b></td><td width='55%' bgcolor='#E8FFE8'>" & REP_NO_PASS & "</td></tr>")
    ts.WriteLine("<tr><td width='45%' bgcolor='#FFE6FF'><b><font face='Tahoma' size='2'>Total VPs Failed</font></b></td><td width='55%' bgcolor='#FFE6FF'>" & REP_NO_FAIL & "</td></tr>")
    ts.WriteLine("<tr><td width='45%' bgcolor='#FF9933'><b><font face='Tahoma' size='2'>Total Warnings</font></b></td><td width='55%' bgcolor='#FF9933'>" & REP_NO_WARN & "</td></tr>")
    ts.WriteLine("<tr><td width='45%' bgcolor='#F2F2F2'><b><font face='Tahoma' size='2'>Total Info Messages</font></b></td><td width='55%' bgcolor='#F2F2F2'>" & REP_NO_INFO & "</td></tr>")
    ts.WriteLine("<tr><td width='45%' bgcolor='#FFFFDC'><b><font face='Tahoma' size='2'>Executed On</font></b></td><td width='55%' bgcolor= '#FFFFDC'>" & Date & "</td></tr>")
    ts.WriteLine("<tr><td width='45%' bgcolor='#FFFFDC'><b><font face='Tahoma' size='2'>Start Time</font></b></td><td width='55%' bgcolor= '#FFFFDC'>" & REP_START_TIME & "</td></tr>")
    ts.WriteLine("<tr><td width='45%' bgcolor='#FFFFDC'><b><font face='Tahoma' size='2'>End Time</font></b></td><td width='55%' bgcolor= '#FFFFDC'>" & REP_END_TIME & "</td></tr>")
    ts.WriteLine("<tr><td width='45%' bgcolor='#FFFFDC'><b><font face='Tahoma' size='2'>Execution Time</font></b></td><td width='55%' bgcolor= '#FFFFDC'>" & DateDiff("s",REP_START_TIME,REP_END_TIME) & " Seconds" & "</td></tr>")
    ts.WriteLine("</table>")
    ts.WriteLine("</font>")
    ts.WriteLine("</body>")
    ts.WriteLine("</html>")

    End Function

    Function REP_CloseFile()

    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

    End Function

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


    And here's the calling functions


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

    ' *----------------------------------------------*
    ' * Description: Wrapper for a passed check *
    ' * Author: Mark Smith *
    ' * Date 28-May-2015 *
    ' *----------------------------------------------*

    Sub REP_PASS(iBrowser, sFileName, sLogStep, sLogMessage)

    sFileName = sFileName & MISC_DateTime(Now)
    LOG_ScreenShot iBrowser, sFileName
    Call REP_AddNewLine(REP_STEP, sLogStep, sLogMessage, sFileName, "Pass")
    REP_STEP = REP_STEP + 1

    End Sub


    ' *-------------------------------------------------*
    ' * Description: Wrapper for a non-fatal Warning *
    ' * Author: Mark Smith *
    ' * Date 28-May-2015 *
    ' *-------------------------------------------------*

    Sub REP_WARNING(iBrowser, sFileName, sLogStep, sLogMessage)

    sFileName = sFileName & MISC_DateTime(Now)
    LOG_ScreenShot iBrowser, sFileName
    Call REP_AddNewLine(REP_STEP, sLogStep, sLogMessage, sFileName, "Warn")
    REP_STEP = REP_STEP + 1

    End Sub


    ' *----------------------------------------------*
    ' * 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)

    Call REP_AddNewLine(REP_STEP, sLogStep, sLogMessage, "Info", "Info")
    REP_STEP = REP_STEP + 1

    End Sub


    ' *----------------------------------------------*
    ' * 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

    msg = Now & " : " & slogStep & " : " & slogMessage

    objFile.WriteLine msg

    objFile.Close

    Set objFSO = Nothing
    Set objFile = Nothing

    End Sub

    ' *---------------------------------------------------------*
    ' * 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

    End Sub

  9. #9
    Member
    Join Date
    Sep 2007
    Location
    Australia
    Posts
    359
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    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.

    Can the above code aid in that?


    Joe
    Attached Files Attached Files

  10. #10
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Kew Gardens, United States
    Posts
    2,650
    Post Thanks / Like
    Blog Entries
    1
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    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.

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 7.14%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:00 PM.

Copyright BetaSoft Inc.