How to customize QTP Result File – UFT A simple function

UFT generates a very good and detailed result for the test run. It can be generated in xml and html both formats after the upgradations brought by UFT.

Still, if you want to generate the result in a different way, there is a way we to customize qtp/UFT generated test result log file.
This function modifies the result logging function of QTP/UFT and generates a very beautiful color coded  and detailed statement for each step.

Go ahead and try this function to customize qtp result report as an html report.

Code to customize QTP result files

CustomResult micFail, "ObjectStep","Actual result","Expected result"

Function CustomResult(nStatus, sStep, sActual, sExpected)
  
  Set oEventDesc = CreateObject("Scripting.Dictionary")   
  oEventDesc("ViewType") = "Sell.Explorer.2"   
  oEventDesc("Status") = nStatus   
  oEventDesc("EnableFilter") = False   
  oEventDesc("NodeName") = sStep

  Dim sHTMLInfo   
  sHTMLInfo = "<TABLE border='0'>"   
  If nStatus = 1 Then    
  sHTMLInfo = sHTMLInfo & "<TR><TD><font color='red' size='2'>Actual Result: " & sActual & "</font></TD></TR>"   
  Else    
  sHTMLInfo = sHTMLInfo & "<TR><TD><font color='green' size='2'>Actual Result: " & sActual & "</font></TD></TR>"   
  End If

  sHTMLInfo = sHTMLInfo & "<TR><TD><font color='blue' size='2'>Expected Result: " & sExpected & "</font></TD></TR></TABLE>"                      
  oEventDesc("StepHtmlInfo") = sHTMLInfo  
  newEventContext = Reporter.LogEvent ("Replay",oEventDesc,Reporter.GetContext)
 
End Function

How to use this function to customize QTP result

Using this function is very simple. You can just copy this function in your function library. For logging any step, in place of writing Reporter.ReportEvent , call the above function same way as it is called in the first line. This will customize qtp result in a very beautiful html report.


Discover more from Automation Script

Subscribe to get the latest posts sent to your email.

Related Posts