public class ExtentReports extends Object
Project URL: http://relevantcodes.com/extentreports-for-selenium/
| Constructor and Description |
|---|
ExtentReports() |
| Modifier and Type | Method and Description |
|---|---|
void |
attachScreenshot(String screenCapturePath)
Allows attaching a snapshot as a step.
|
void |
attachScreenshot(String screenCapturePath,
String message)
Allows attaching a snapshot as a step.
|
DocumentConfig |
config()
Returns the DocumentConfig object that allows various configurations to be applied
to the report file
|
void |
endTest()
Ends the current toggle level
|
static ExtentReports |
get(Class<?> clazz) |
static ExtentReports |
get(String className) |
void |
init(String filePath,
Boolean replaceExisting)
Initializes the reporting by setting the file-path
|
void |
init(String filePath,
Boolean replaceExisting,
DisplayOrder displayOrder)
Initializes the reporting by setting the file-path and test DisplayOrder
|
void |
init(String filePath,
Boolean replaceExisting,
DisplayOrder displayOrder,
GridType gridType)
Initializes the reporting by setting the file-path, test DisplayOrder and GridType
|
void |
init(String filePath,
Boolean replaceExisting,
GridType gridType)
Initializes the reporting by setting the file-path and GridType
|
void |
log(LogStatus logStatus,
String details)
Overloaded method to allow only setting the LogStatus and details of the log event
|
void |
log(LogStatus logStatus,
String stepName,
String details)
Overloaded method to allow LogStatus, stepName and details for the log event
|
void |
log(LogStatus logStatus,
String stepName,
String details,
String screenCapturePath)
Provides ability to log events for each started test.
|
void |
setLogLevel(LogLevel logLevel)
This allows a log level for the report.
|
void |
startTest(String testName)
Calling startTest(arg) generates a toggle for the test in the HTML file and adds all
log events under this level.
|
void |
startTest(String testName,
String testDescription)
Calling startTest(arg, arg) generates a toggle for the test in the HTML file and adds all
log events under this level.
|
public static ExtentReports get(Class<?> clazz)
clazz - The class that uses a region level ExtentReports objectpublic static ExtentReports get(String className)
className - The name of the class that uses a region level ExtentReports object, passed as a stringpublic void startTest(String testName)
Usage: extent.startTest("MyTestName");
testName - Name of the test that is currently being run and report is being generated forpublic void startTest(String testName, String testDescription)
This overloaded method allows a description to be written for the testName.
Usage: extent.startTest("Test - With Description", "This description will show up under Test.");
testName - Name of the test that is currently being run and report is being generated fortestDescription - Description of the testpublic void endTest()
public void log(LogStatus logStatus, String stepName, String details, String screenCapturePath)
Usage: extent.log(LogStatus.INFO, "Image", "Image example:", "C:\\img.png");
It is possible to use relative path for the snapshot. Note: Relative paths starting with '/' and '.' are supported. If you are using an absolute path, 'file:///' will be automatically appended for the image to load correctly.
Usage
extent.log(LogStatus.INFO, "Image", "Image example:", "./pathToImg.png");
extent.log(LogStatus.INFO, "Image", "Image example:", "/pathToImg.png");
logStatus - LogStatus of the log eventstepName - Name of the stepdetails - Details of the stepscreenCapturePath - Path of the snapshot to be attached to steppublic void log(LogStatus logStatus, String stepName, String details)
Usage: extent.log(LogStatus.PASS, "StepName", "PASS Details");
logStatus - LogStatus of the log eventstepName - Name of the stepdetails - Details of the steppublic void log(LogStatus logStatus, String details)
Usage: extent.log(LogStatus.INFO, "This step shows usage of log(logStatus, details)");
logStatus - LogStatus of the log eventdetails - Details of the steppublic void attachScreenshot(String screenCapturePath, String message)
Usage: extent.attachScreenshot("pathToImg.png", "This step only attaches a screenshot without a status.");
It is possible to use relative path for the snapshot. Note: Relative paths starting with '/' and '.' are supported. If you are using an absolute path, 'file:///' will be automatically appended for the image to load correctly.
screenCapturePath - Path of the snapshot filemessage - Message to attach for the steppublic void attachScreenshot(String screenCapturePath)
Usage: extent.attachScreenshot("pathToImg.png");
It is possible to use relative path for the snapshot. Note: Relative paths starting with '/' and '.' are supported. If you are using an absolute path, 'file:///' will be automatically appended for the image to load correctly.
screenCapturePath - Path of the snapshot filepublic void setLogLevel(LogLevel logLevel)
ALLOW_ALL: default setting which passes all log events to the report
FAIL: Allows FAIL and FATAL events sent to the report
WARNING: Allows WARNING and FAIL events to be sent to the report
ERROR: Allows ERROR and FAIL events to be sent to the report
ERRORS_AND_WARNING: Allows Errors, Warnings and FAIL/FATAL events
OFF: No events are allowed to be written to the report
logLevel - Level of logging to be usedpublic DocumentConfig config()
public void init(String filePath, Boolean replaceExisting)
filePath - Path of the file, in .htm or .html formatreplaceExisting - Setting to overwrite (TRUE) the existing file or append (FALSE) to it
using the DisplayOrder order
true: the file will be replaced with brand new markup,
and all existing data will be lost. Use this option to create a brand new report
false: existing data will remain, new tests will be appended to the existing reportpublic void init(String filePath, Boolean replaceExisting, DisplayOrder displayOrder)
filePath - Path of the file, in .htm or .html formatreplaceExisting - Setting to overwrite (TRUE) the existing file or append (FALSE) to it
using the DisplayOrder order
true: the file will be replaced with brand new markup,
and all existing data will be lost. Use this option to create a brand new report
false: existing data will remain, new tests will be appended to the existing reportdisplayOrder - Determines the order in which your tests will be displayed
BY_OLDEST_TO_LATEST (default) - oldest test at the top, newest at the end
BY_LATEST_TO_OLDEST - newest test at the top, oldest at the endpublic void init(String filePath, Boolean replaceExisting, GridType gridType)
filePath - Path of the file, in .htm or .html formatreplaceExisting - Setting to overwrite (TRUE) the existing file or append (FALSE) to it
using the DisplayOrder order
true: the file will be replaced with brand new markup,
and all existing data will be lost. Use this option to create a brand new report
false: existing data will remain, new tests will be appended to the existing reportgridType - Determines the type of grid to be used
STANDARD (default) - standard grid with 1 test per row
MASONRY - creates a masonry style grid with 2 tests per rowpublic void init(String filePath, Boolean replaceExisting, DisplayOrder displayOrder, GridType gridType)
filePath - Path of the file, in .htm or .html formatreplaceExisting - Setting to overwrite (TRUE) the existing file or append (FALSE) to it
using the DisplayOrder order
true: the file will be replaced with brand new markup,
and all existing data will be lost. Use this option to create a brand new report
false: existing data will remain, new tests will be appended to the existing reportdisplayOrder - Determines the order in which your tests will be displayed
BY_OLDEST_TO_LATEST (default) - oldest test at the top, newest at the end
BY_LATEST_TO_OLDEST - newest test at the top, oldest at the endgridType - Determines the type of grid to be used
STANDARD (default) - standard grid with 1 test per row
MASONRY - creates a masonry style grid with 2 tests per rowCopyright © 2015. All rights reserved.