How can we share the HTML report from testng framework which will downloaded in Reports folder as link to others

108 views
Skip to first unread message

Soumya s

unread,
Mar 17, 2023, 7:49:17 AM3/17/23
to testng-users
How can we share the HTML report from testng framework which will downloaded in Reports folder as url link to other users.Kindly provide solution on this.

Soumya s

unread,
Mar 17, 2023, 7:55:23 AM3/17/23
to testng-users
HTML report is nothing but ExtentReport from TestNG.

⇜Krishnan Mahadevan⇝

unread,
Mar 17, 2023, 8:26:16 AM3/17/23
to testng...@googlegroups.com
You build an implementation of IExecutionListener, which would look for the extent reports (in whatever directory that exists), then it would zip the folder and perhaps send it as an email (using JavaMail apis)



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/06f88398-1bf9-4213-aaef-224e540791dfn%40googlegroups.com.

Soumya s

unread,
Mar 20, 2023, 1:13:21 AM3/20/23
to testng-users
Hi Krishan,

Thanks for information. I have already implemented  IExecutionListener, but how can we send link[like grafan link] of execution report,[when user clicks on link, they should be able to view the result] instead of email. OR how can we include the any automatic generation of link in Listenerclass.[Like grafan link]
Could be grateful, if you could help me in this.

Thanks and Regards,
Soumya S.

⇜Krishnan Mahadevan⇝

unread,
Mar 20, 2023, 1:15:00 AM3/20/23
to testng...@googlegroups.com
You are better off building your own custom TestNG reporter by implementing IReporter.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/

Soumya s

unread,
Mar 20, 2023, 1:24:16 AM3/20/23
to testng-users
Could you please suggest, how can we do it. Below is my listener class which extends ExtentReporter.
package test.Listener;
import java.io.IOException;

import org.openqa.selenium.WebDriver;
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.Status;

import generic.BaseTest;
import generic.ExtentReporterNG;
import generic.GenericUtils;


public class Listeners extends BaseTest implements ITestListener {

ExtentTest test;

ExtentReports extent = ExtentReporterNG.getReportObject();
//ExtentReports extent = ExtentReporterNG.getReportObject();

@Override
public void onTestStart(ITestResult result) {
test= extent.createTest(result.getMethod().getMethodName());
}
@Override
public void onTestSuccess(ITestResult result)
{
test.log(Status.PASS,"Test Passed");
}
@Override
public void onTestFailure(ITestResult result)
{
test.fail(result.getThrowable());

try {
driver = (WebDriver) result.getTestClass().getRealClass().getField("driver")
.get(result.getInstance());
} catch (Exception e1) {

e1.printStackTrace();
}

String filePath="null";

try {
filePath = getScreenshot(result.getMethod().getMethodName(),driver);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
test.addScreenCaptureFromPath(filePath, result.getMethod().getMethodName());
}

@Override
public void onTestSkipped(ITestResult result)
{
{

test.skip(result.getThrowable());

try {
driver = (WebDriver) result.getTestClass().getRealClass().getField("driver")
.get(result.getInstance());
} catch (Exception e1) {

e1.printStackTrace();
}

String filePath="null";

try {
filePath = getScreenshot(result.getMethod().getMethodName(),driver);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
test.addScreenCaptureFromPath(filePath, result.getMethod().getMethodName());
}
}


@Override
public void onStart(ITestContext context)
{
}
@Override
public void onFinish(ITestContext context)
{
extent.flush();
}
}

⇜Krishnan Mahadevan⇝

unread,
Mar 20, 2023, 1:26:10 AM3/20/23
to testng...@googlegroups.com
You would have to look at the api of ExtentReports to figure out how to customize it. I have personally not used ExtentReports, so I will step aside and let someone else help you more aptly.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/

Reply all
Reply to author
Forward
0 new messages