In this post we will discuss about how to generate Extent reports in UFT.
Source code is available below
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
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.
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
LikeLike
It’s not going to work unless you register the DLL file as codebase. Path of regasm is provided in the post. You should be able to register the file.
LikeLike
Do I have to register for all the Dll’s which is available in the UFT_EXTENT_REPORTS ?
LikeLike
Bcoz Iam getting the below error in UFT even after succeeded with the ExtentReports_UFT.dll
LikeLike
I am getting the below error in UFT
LikeLike
“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.”
LikeLike
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
LikeLike
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;
LikeLike
Wonderful post sumeet, Thanks for the same. 🙂
LikeLiked by 1 person
Thanks.
LikeLike
Wonderful post sumeet, Thanks for the same:)
LikeLiked by 1 person
Thanks..
LikeLike
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.
LikeLiked by 1 person
Hi,
Extent is an open source report and list of all functions are available below
http://extentreports.com/docs/versions/3/net/
All functions available within the API which I created is available in the example above, if you need any other function then please let me know, I will try to add them.
Thanks,
Sumeet Kushwah
LikeLike
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?
LikeLike
Not yet, but I will publish this code on github and then you can expose any function you want to use. I will send you the link of github soon.
LikeLike
Thank you so much Sumeet, Hoping to see it soon:)
LikeLike
Below is the code for the DLL
https://github.com/sumeet-kushwah/UFT_ExtentReports
if you make any changes which you think will be helpful for others then please share the code with me. I will update it in the repository.
LikeLike
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”
LikeLike
Can you post your script ?
Thanks,
Sumeet Kushwah
LikeLike
Sorry Summit, it was my fault. I missed to call the GenerateReport() method. Now it s working fine. Thanks!!!
LikeLike
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!!!
LikeLike
I dont think so, but I will check and let you know.
LikeLike
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.
LikeLike
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!
LikeLike
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”)
LikeLike
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?
LikeLike
AddSystemInfo is not coded into this api yet. I will update the code and release an updated version soon.
Thanks,
Sumeet
LikeLike
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.
LikeLike
Have you tried keeping the screenshots and reports in the same folder and just provide the screenshot file name in the extent reports ?
LikeLike
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?
LikeLike
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.
https://sumeetkushwah.com/2014/08/14/machine-cleanup-framework-for-uftqtp-2/
If you need help with your setup then you can drop me an email using the contact form
https://sumeetkushwah.com/about/
Thanks,
Sumeet Kushwah
LikeLike
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.
LikeLike
Hey Sumeet – What version of UFT do I need (min) to be able to perform the above ?. Many thanks.
LikeLike
You can use any recent versions. I have tried it on 11, 12 and 14.
LikeLike
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.
LikeLike
Not yet, but it’s a good idea. I have uploaded the code to git server, you can update it if you want to make any changes. I will try to include the config file.
LikeLike
Thanks so much! waiting for your new update on this.
LikeLike
This feature is available in version 2. Please try
LikeLike
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”);
LikeLike
Please download version 2 and try the new features.
LikeLike
Hello Sumeet, Could you please tell me the exact method with parameters.
I’m trying below method. its not working-
htmlReporter.addSystemInfo(“Environment”,”QA”)
LikeLike
Yes Sumeet, got it how to use it. below is the correct line. we have to add call before method name.
call htmlReporter.addSystemInfo(“Environment”,”QA”)
LikeLike
Great.. I was about to reply to your message.
LikeLike
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
LikeLike
I have used this type of code but extent reports are much better option. Also your code doesn’t seem to generate any graphs, if you want to add pass/fail percent graph, I can send to that code.
LikeLike
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?
LikeLike
Can u send me the output
LikeLike
Hi Sumit..I am also getting the same issue..Three HTML files are generated instead og one
LikeLike
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
LikeLike
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!
LikeLike
Hi Sumeet,
Can you please help me to embed screenshot in the extent report.
Thanks!
LikeLike
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.
LikeLike
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?
LikeLike
It should be generated automatically. Please click around and check.
LikeLike
No it is not generating steps and also I am getting 3 html files, dashboard, index and tags
LikeLike
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
LikeLike
Yes.
LikeLike
Since alot of people are having the issue, I am going to try to create the reports and update the library if required with the latest Extent report updates over the weekend.
LikeLike
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..
LikeLike
We are using latest Extent Report vesion only…
LikeLike
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…
LikeLike