How to print the selenium exception stack trace in Extent reports

extent reports customization
extent-config.xml selenium
extent report version 3
loadconfig in extent report
extent-config.xml c#
extent report version 4
extent report configuration in selenium
extent reports api dashboard

I would like log comments after each step in a Selenium test in Extent reports. Therefore, when an exception thrown in a step, I would like to capture the stack trace and print it out on the Extent Reports. I could not find any help on line. Has anyone tried this before and found a way?

For example, the below create an instance of the report and log the comment

// new instance

ExtentReports extent = new ExtentReports(file-path, replaceExisting);

// starting test

ExtentTest test = extent.startTest("Test Name", "Sample description");

// step log

test.log(LogStatus.INFO, "Click on the object");


If you want to log the stack trace of the exception you can convert the Exception stack trace to String. This class is available in Apache commons-lang-3.3.4 jar ExceptionUtils.getStackTrace(e)

Simple Example

             int num[]={1,2,3,4};
        }catch(Exception e){        
        test.log(LogStatus.INFO/ERROR, ExceptionUtils.getStackTrace(e));

Hope this Helps you...Kindly get back if you have any queries

Write stack trace to Extent Reports from the @afterMethod in TestNG , Simply pass throwable to the log and the exception will be printed correctly. Reference:� 1.printStackTrace(): prints the stack trace , exception name and description. 2.toString(): returns a text message describing the exception name and description. 3.getMessage(): displays the description of exception. These three methods are present in Throwable class.

Or you can simply do

catch (Exception e) {
    test.log(LogStatus.FAIL, e);

Enhancement:Printing stack trace in separate lines � Issue #269 , Hi Ansho, in the report exception is getting printed in merged lines,could you please change it to anshooarora / extentreports-java Archived. With Log4j2 and other logging frameworks, you can pass the exception as a parameter to the logging method. By default, Log4j2 logs the exception’s stack trace along with the message provided. By extending Log4j2’s PatternLayout, or by switching to a more structured layout, you can include more detailed information about the stack trace.

Since ExceptionUtils is deprecated

test.log(LogStatus.INFO/ERROR, ExceptionUtils.getStackTrace()); ->this won't help

So we can use

test.log(Status.INFO, "StackTrace Result: " + Thread.currentThread().getStackTrace());

java: How to print the selenium exception stack trace in Extent reports, I would like log comments after each step in a Selenium test in Extent reports. Therefore, when an exception thrown in a step, I would like to capture the stack� Community-based solutions like Extent Reports or Allure are quite impressive, but usually are hard to set up and often need a lot of tweaking to get the level of detail that many users want in their reports. With Silk Test 18.0, you can use the TrueLog technology for your existing Selenium tests with minimal configuration effort.

Java, extent = new ExtentReports(outputDirectory + File.separator + This listener will create an ExtentReports report called ExtentReportTestNG.html in the default TestNG output if it's long) your implementation and the stack trace? I am able to get the exception text but I want to get the screenshot also. Extent Report is an HTML reporting library for Selenium WebDriver for Java which is a great degree simple to use and makes excellent execution reports. We can use this tool within our TestNG automation framework.

Using the ExtentReports TestNG listener in Selenium Page Object , Insert Screenshots in Extent Reports - In this post, we see how to add Screenshots in String screenshotName) throws Exception { //below line is just to append the public static String getScreenshot(WebDriver driver, String getProperty("user.dir") +"/test-output/STMExtentReport.html", true); //extent. Hi Karthik, one approach you might take is to create separate testng.xml files for every browser and parameterize the browser type. Then, in the @BeforeSuite, you can simply instantiate the desired browser based on the value of that variable using an if-then-else or case-statement.

Extent Reports, Extent Reports 3 0 | Extent Reports Log Generation in Selenium,In this video you' ll learn Duration: 12:49 Posted: Jan 29, 2018 these reports are not primarily meant to be used in combination with Jira or Quality Center, but as a standalone means of reporting on test results. If you want to report your test results from Selenium to Jira, first of all you need to ask yourself whether you want to report test results or just issues.