Creating Extent Reports in UFT

In this post we will discuss about how to generate Extent reports in UFT.

Source code is available below

Source Code

Introduction

Extent reports are widely used HTML run result reports. They are used with Selenium frameworks and BDD Frameworks. As of now this report is not available for UFT because its only developed for .Net and Java based projects.

How this will work?

We will create a COM visible.net class and this class will expose the functionalities of extent reports to UFT. All of the DLL’s are available below for download

Download Version 1

Download Version 2

Register the COM Libraries

To register the Libraries use the following command.

Regasm.exe ExtentReports_UFT.DLL /codebase
**Regasm.exe is available under the below folder

C:\Windows\Microsoft.NET\Framework\V4.x.xxxx\Regasm.exe

Pick a folder with name v4.x.

Generate the Extent reports in UFT

    Set htmlReporter = CreateObject("UFT_Extent_Reports.HTMLReporter")
    htmlReporter.InitializeReport("C:\temp\Extent.html")
    htmlReporter.AddReportName("TEST AUTOMATION REPORT")
    htmlReporter.AddDocumentTitle("This is a Document title")

    '''Create a new test
    htmlReporter.CreateTest("FirstTest")
    call htmlReporter.AssignAuthorToTest("Sumeet Singh Kushwah")
    call htmlReporter.AssignCategoryToTest("Regression")

    ''' Add Logs to the test
    call htmlReporter.AddInfoLog("Test Started")
    call htmlReporter.AddErrorLog("Test Error")
       call htmlReporter.AddFailLog("Test Failed", "C:\temp\Google.png")
       call htmlReporter.AddFailLog("Test Failed - With Long error", "C:\temp\Google.png")

    ''''Create another test
    htmlReporter.CreateTest("Second Test")
    call htmlReporter.AssignAuthorToTest("Sumeet Singh Kushwah")
    call htmlReporter.AssignCategoryToTest("Functional")

    ''' Add Logs to the test
    call htmlReporter.AddInfoLog("Test Setp1")
    call htmlReporter.AddInfoLog("Test Step 2")
    call htmlReporter.AddPassLog("Test Step Passed","C:\temp\Google.png")
    call htmlReporter.AddFatalLog("Test Step Passed","C:\temp\Google.png")

    '''Change Theme to dark
    htmlReporter.ChangeToDarkTheme

    ''Generate the html reports
    htmlReporter.GenerateReport()

Below is the snapshot of the generated report.

Let me know if you have any questions.

62 responses to “Creating Extent Reports in UFT

  1. It is throwing an error as “Run Time Error” for the line ” Set htmlReporter = CreateObject(“UFT_Extent_Reports.HTMLReporter”)”.

    I did all the steps mentioned. However, I am not sure how to perform for “Regasm.exe ExtentReports_UFT.DLL /codebase”. I did for “Regasm.exe ExtentReports_UFT.DLL” ( This was successful ), but the “/codebase” is what I am confused.

    Can you please help

    Like

      • Do I have to register for all the Dll’s which is available in the UFT_EXTENT_REPORTS ?

        Like

      • Bcoz Iam getting the below error in UFT even after succeeded with the ExtentReports_UFT.dll

        Like

      • “Could not load file or assembly ‘ExtentReports, Version=3.0.2.1, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.”

        Like

      • Hi Sumeet,
        Registered using Regasm.exe ExtentReports_UFT.DLL /codebase.
        But getting error “ActiveX component can’t create object: ‘UFT_Extent_Reports.HTMLReporter’
        Line (3): “Set htmlReporter = CreateObject(“UFT_Extent_Reports.HTMLReporter”)”

        Could you please help? what could be the issue.

        Regards,
        Bala

        Like

      • Need your help. i opened the project in VS 2019 , i am seeing error
        ExtentHtmlReporter does not contain definition Config …
        ExtentHtmlReporter.Config.Theme = Theme.Standard;

        Like

  2. Hi Sumeet, Could you please also tell us how to know and call for the different functions available in extent reports, like u have used below

    call htmlReporter.AssignAuthorToTest(“Sumeet Singh Kushwah”)
    call htmlReporter.AssignCategoryToTest(“Functional”)

    Kindly assist:)
    Thank you.

    Liked by 1 person

  3. Thanks for your reply Sumeet, I have been using extent reports API for Selenium and testNG, but my question is can we use all those functions available in Extent API using above provided DLL’s?

    Like

  4. Hi Sumeet,
    I tried to use the extent reports with UFT but it is not working. UFT is simply running without throwing any error but no report is generated at the path specified in the script. Please help me!

    While registering the dll, I got the below warning:

    RegAsm : warning RA0000 : Registering an unsigned assembly with /codebase can ca
    use your assembly to interfere with other applications that may be installed on
    the same computer. The /codebase switch is intended to be used only with signed
    assemblies. Please give your assembly a strong name and re-register it.
    Types registered successfully”

    Like

  5. Hi Summit, is it possible to append the report generated to already existing extent html report?
    If yes, could you explain how. Thanks in Advance!!!

    Like

  6. Could you place dlls in Github.It would be a great help as gdrive is blocked in our organization..Also ,if you could tell us step by step description of steps you followed to achieve this,we can implement in our company.

    Like

  7. Hi Sumeet…Thanks for your post on How to create Extent report in UFT. I am able to register library via command “Regasm.exe ExtentReports_UFT.DLL /codebase”. And I am able to register it successfully as shown below:

    Microsoft .NET Framework Assembly Registration Utility version 4.7.2046.0
    for Microsoft .NET Framework version 4.7.2046.0
    Copyright (C) Microsoft Corporation. All rights reserved.

    RegAsm : warning RA0000 : Registering an unsigned assembly with /codebase can cause your assembly to interfere with other applications that may be installed on the same computer. The /codebase switch is intended to be used only with signed assemblies. Please give your assembly a strong name and re-register it.
    Types registered successfully

    When I call create object of “UFT_Extent_Reports.HTMLReporter” in UFT it showing error as “Expected statement”. Do I need to add something in test script as well?? As of now my script is simple to open a browser with google link.
    Kindly let me know if I am missing something!
    Thanks!

    Like

    • Hi…
      I am able to solve “Expected statement error”.
      But Now I am getting “Run Error” while generating report using function htmlReporter.GenerateReport(). Below are the details:

      Errors while compiling a Template.
      Please try the following to solve the situation:
      * If the problem is about missing/invalid references or multiple defines either try to load
      the missing references manually (in the compiling appdomain!) or
      Specify your references manually by providing your own IReferenceResolver implementation.
      See https://antaris.github.io/RazorEngine/ReferenceResolver.html for details.
      Currently all references have to be available as files!
      * If you get ‘class’ does not contain a definition for ‘member’:
      try another modelType (for example ‘null’ to make the model dynamic).
      NOTE: You CANNOT use typeof(dynamic) to make the model dynamic!
      Or try to use static instead of anonymous/dynamic types.
      More details about the error:
      – error: (0, 0) The type ‘System.Attribute’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.
      Temporary files of the compilation can be found in (please delete the folder): C:\Users\rsharm56\AppData\Local\Temp\RazorEngine_uqwwm1me.ire
      The template we tried to compile is:
      ————- START ———–
      @using RazorEngine
      @using RazorEngine.Templating
      @using AventStack.ExtentReports.Reporter.Configuration.Defaults

      @Include(“head”)

      @{
      var t = Model.TestList[0];
      var bdd = t.HasChildren() && t.NodeContext().Get(0).IsBehaviorDrivenType;

      var bddClass = “”;
      if (bdd)
      {
      bddClass = “bdd”;
      }
      }

      desktop_windows

      @Include(“nav”)

      @Include(“test”)
      @Include(“category”)
      @Include(“exception”)
      @Include(“dashboard”)
      @Include(“logs”)

      Like

  8. HI Sumeet,
    I was trying to create extent HTML reporting in UFT. I am facing issue while using AddSystemInfo function. I am getting below error:
    “object doesn’t support this property or method: ‘htmlReporter.AddSystemInfo’ “.
    What could be the reason for it?

    Like

  9. Hi Sumeet ..can u help me out in implementing the relative path for the screen shot in the Extent report..??..so that it can be accessed in any other system or email.

    Like

  10. Thanks Sumeet for your reply. I am able to add screen shots. I have a query regarding generating report. Can we call GenerateReport() function after end of each test case rather than calling in the end of test suite? Will all the Test case reports will append in one extent report if we call generatereport() function after end of each test case? The reason behind is if let say TC no 1, 2 run well but while running TC 3 application crashes then we are not able to get report of TC 1 and 2 as well. please suggest?

    Like

    • Yes, GenerateReport() can be called after each test, it should only replace the existing report and should work ideally, I have not tested it, but let me know if you face any issues, I can resolve them. Also I think you should look into this article about creating a class destructor which will be called automatically at the end of each execution, that way even if the execution is stopped abruptly, you will have the results, I have seen it working in the scenarios where UFT died in the middle of executions.

      Machine cleanup Framework for UFT/QTP

      If you need help with your setup then you can drop me an email using the contact form

      About

      Thanks,
      Sumeet Kushwah

      Like

      • We tried calling GenerateReport() after execution of each test but it generate report with multiple copies of screenshot and its related information.
        For example: Let say we have test suite with 5 test cases and at end of each test case we are calling GenerateReport(). so now if we execute test case 1,2,3,4 and 5. GenerateReport() will be called 5 times, which creates a Single report with 5 screenshot of same screen. (for test case 1 report is created fine but from test case 2 onwards 2,3,4,5 screenshots are appended depending on the run count)
        Please help on this as we tried with different alternatives but couldn’t find resolution.

        Like

  11. Hello Sumeet, Thanks so mush for this wonderful blog. we have used this DLL for our project. it was awesome. Good Job man.
    I have a question here – Do we have “Extent-Config.xml” file to customize the extent report as per our need like selenium api.

    Like

  12. Hello Summet,

    Do we have a method (addSystemInfo) below mentioned, in DLL – Like Selenium. It would help us to add the environment details in Extent report. If not, could you please add this method DLL

    extent.addSystemInfo(“Environment”,”Environment Name”)
    extentort.setSystemInfo(“Browser”, “Chrome Version 64.0.3282”);
    extent.setSystemInfo(“Version”, “R12”);

    Like

  13. Please use below Code for better HTML Report
    :

    Function func_HTML_Report()
    ‘On error resume next
    dim strHTMLFileName
    Dim strObjective, strActualResult,strPassFail,Strfilename
    Dim EndTime
    gbReportFilePath= “C:\Users\A50783376\Desktop\Test”
    strHTMLFileName= gbReportFilePath & “\TestResult_” & Day(now) & “_” & month(now) & “_” & year(now) & “_” & hour(now) & “_” & minute(now) &”.html”
    StartTime = Timer
    stTime = Time
    Set fso = CreateObject(“Scripting.FileSystemObject”)
    Set htmlresult = fso.CreateTextFile(strHTMLFileName, ForWriting, True)
    ‘OpenTextFile(strHTMLFileName, ForWriting, True)
    strFileURL = strHTMLFileName
    htmlresult.writeline(“”)
    htmlresult.writeline(“TestName”)
    htmlresult.WriteLine(“”)
    htmlresult.WriteLine(“”)
    htmlresult.WriteLine(“”)
    htmlresult.WriteLine(” Automation Test Results”)
    htmlresult.writeline(“”)
    htmlresult.writeline(“”)
    htmlresult.writeline(“TestCaseID“)
    htmlresult.writeline(“Testcase Description“)
    htmlresult.writeline(“Expected Result“)
    htmlresult.writeline(“ Result “)
    htmlresult.writeline(“Pass/Fail“)
    htmlresult.writeline(“Screenshot“)
    htmlresult.writeline(“”)
    ‘strScreenshot=”K:\everyone\QA_Coimbatore\error.png”
    strTCID= 2
    strObjective= “Check Login Functionlity”
    strExpectedResult= “Login should be successfull”
    strActualResult= “Login Successfull”
    strPassFail= “pass”
    htmlresult.writeline(“”)
    htmlresult.writeline(“” & strTCID & “”)
    htmlresult.writeline(“” & strObjective & “”)
    htmlresult.writeline(“” & strExpectedResult & “”)
    htmlresult.writeline(“” & strActualResult & “”)
    screenshot = “C:\Users\A50783376\Desktop\Test\error.jpeg”
    if lcase(strPassFail) = “pass” then
    ‘CaptureScreenshot
    htmlresult.writeline(“” & strPassFail & ““)
    intPass = intPass + 1
    ElseIf lcase(strPassFail) = “fail” Then
    ‘CaptureScreenshot
    htmlresult.writeline(“”)
    htmlresult.writeline(“” & strPassFail & ““)
    htmlresult.writeline(“ Error Message “)
    intFail = intFail + 1
    else
    htmlresult.writeline(“ Not applicable “)
    intPass = intPass + 1
    end if
    htmlresult.writeline(“”)
    EndTime = Timer
    enTime = Time
    htmlresult.writeline(“”)
    htmlresult.writeline(“”)
    htmlresult.writeline(“”)
    htmlresult.writeline(“Summary“)
    htmlresult.writeline(“Total Tesresult Passed” & intPass & “”)
    htmlresult.writeline(“Total Tesresult Failed” & intFail & “”)
    htmlresult.writeline(“Execution Url” & gburl & “”)
    htmlresult.writeline(“Executed On” & Date & “”)
    htmlresult.writeline(“Start Time” & stTime & “”)
    htmlresult.writeline(“End Time” & enTime & “”)
    htmlresult.writeline(“Execution Time” & int((CDbl(EndTime – StartTime))/60) & ” Minutes”& “”)
    htmlresult.writeline(“”)
    htmlresult.writeline(“”)
    htmlresult.WriteLine(“”)
    htmlresult.WriteLine(“”)
    htmlresult.close()
    Set objIE = CreateObject(“InternetExplorer.Application”)
    objIE.visible = True
    objIE.Navigate strFileURL
    End Function

    Like

  14. Hi Sumeet,

    Report is not getting generated with the given name. Instead, three html reports with name dashboard, tag and test is generated.
    Could you look into this?

    Like

  15. Hi ,
    while registering the DLL i am getting error on cmd prompt as the filename , directory name , or Volume label syntax is incorrect.
    Can you please suggest

    Like

  16. Thanks for this wonderful blog Sumeet! There are 2 versions of DLLs available in your blog, I just wanted to know if there is any new update available, do you put it in both the versions or any specific version.

    Thanks!

    Like

  17. Thank you Sumeet for this great article. I ‘ve successfully registered DLL’s and working fine. For some reason Extent.html report is missing in not getting created.

    Like

  18. Hi Sumeet, It is very nice one and helpful. Currently I am able to see the tests graph but how to show the test steps graph in the dashboard?

    Like

  19. Hi Sumeet ,This Extent Report integration with UFt is really great and we are using Selnium n UFT for mobile automation.now its easier to generate reports for both UFT and selenium i same format.Really thanks for sharing i was able to install in one system and in other i get error.Please let mw know if i can share error details in this post

    Like

  20. Hi Sumeet, we have implemented Extent Report integration with UFT in my project.
    Reports were generating good. But recently getting Run Error while generating the report.

    Content is : “If the problem is about missing/invalid references or multiple defines either try to load
    the missing references manually (in the compiling appdomain!) or
    Speficy your references manually by providing your own IReferenceResolver implementation.
    If you get ‘class’ does not contain a definition for ‘member’. try another modelType (for example ‘null’ to
    make the model dynamic)……

    Could you please suggest..

    Like

  21. Hi Sumeet, we have implemented Extent Report integration with UFT in my project.
    Reports were generating good. But recently getting Run Error while generating the report.

    Content is : “If the problem is about missing/invalid references or multiple defines either try to load
    the missing references manually (in the compiling appdomain!) or
    Speficy your references manually by providing your own IReferenceResolver implementation.
    If you get ‘class’ does not contain a definition for ‘member’. try another modelType (for example ‘null’ to
    make the model dynamic)……

    We are using latest Extent Report files only…

    Can you pls suggest…

    Like

Leave a comment