How to print the selenium exception stack trace in Extent reports

Rama

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");

Reference:

http://extentreports.relevantcodes.com/java/version2/docs.html#initialize-report

Vicky

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

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

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to print the stack trace of an exception object in Python?

From Dev

How to get stack trace string without raising exception in python?

From Dev

locals() and globals() in stack trace on exception (Python)

From Dev

Rethrow an Exception with correct line numbers in the stack trace

From Dev

How can an Exception be created/thrown with no stack trace?

From Dev

how to print stack trace to stdout in java for debug?

From Dev

Scala: print a stack trace in my Scalatra app

From Dev

How can I make program print a stack trace automatically when an Exception occurs in Android

From Dev

Exception Stack Trace Missing Items

From Dev

Why is the exception stack trace not logged in?

From Dev

How to print the current thread stack trace inside the Linux kernel?

From Dev

How to print stack trace (with symbolic function names) on Android?

From Dev

How to use a stack trace dump to debug an exception?

From Dev

pythonanywhere + flask: website just says 'unhandled exception'. How to get debugger to print stack trace?

From Dev

Print Stack Trace with SuperDevMode is obfusated

From Dev

Print Stack Trace intefering with Print Line

From Dev

logback: newline before exception stack trace but not otherwise?

From Dev

How to print the selenium exception stack trace in Extent reports

From Dev

Exception that emails stack trace when raised

From Dev

Exception stack trace and aggregation in Parallel.ForEach

From Dev

Python exception: how to print the last ten lines of stack trace?

From Dev

How to print the stack trace of an exception object in Python?

From Dev

how to trace this stack and pointer

From Dev

How to get stack trace string without raising exception in python?

From Dev

How to enable crash reports/core dumps/stack trace logging globally?

From Dev

How to print stack trace (with symbolic function names) on Android?

From Dev

How to use a stack trace dump to debug an exception?

From Dev

how to read full exception stack trace from errorChannel

From Dev

How does the console obtain the stack trace of an exception?

Related Related

  1. 1

    How to print the stack trace of an exception object in Python?

  2. 2

    How to get stack trace string without raising exception in python?

  3. 3

    locals() and globals() in stack trace on exception (Python)

  4. 4

    Rethrow an Exception with correct line numbers in the stack trace

  5. 5

    How can an Exception be created/thrown with no stack trace?

  6. 6

    how to print stack trace to stdout in java for debug?

  7. 7

    Scala: print a stack trace in my Scalatra app

  8. 8

    How can I make program print a stack trace automatically when an Exception occurs in Android

  9. 9

    Exception Stack Trace Missing Items

  10. 10

    Why is the exception stack trace not logged in?

  11. 11

    How to print the current thread stack trace inside the Linux kernel?

  12. 12

    How to print stack trace (with symbolic function names) on Android?

  13. 13

    How to use a stack trace dump to debug an exception?

  14. 14

    pythonanywhere + flask: website just says 'unhandled exception'. How to get debugger to print stack trace?

  15. 15

    Print Stack Trace with SuperDevMode is obfusated

  16. 16

    Print Stack Trace intefering with Print Line

  17. 17

    logback: newline before exception stack trace but not otherwise?

  18. 18

    How to print the selenium exception stack trace in Extent reports

  19. 19

    Exception that emails stack trace when raised

  20. 20

    Exception stack trace and aggregation in Parallel.ForEach

  21. 21

    Python exception: how to print the last ten lines of stack trace?

  22. 22

    How to print the stack trace of an exception object in Python?

  23. 23

    how to trace this stack and pointer

  24. 24

    How to get stack trace string without raising exception in python?

  25. 25

    How to enable crash reports/core dumps/stack trace logging globally?

  26. 26

    How to print stack trace (with symbolic function names) on Android?

  27. 27

    How to use a stack trace dump to debug an exception?

  28. 28

    how to read full exception stack trace from errorChannel

  29. 29

    How does the console obtain the stack trace of an exception?

HotTag

Archive