ExtentReports (by Anshoo Arora) is a HTML reporting library for
Selenium WebDriver for Java and creates easy to use, attractive reports.
It shows test and step summary, test steps and status in a toggle view
for quick analysis.
View ExtentReports sample
here.
Index
What’s new in version 1.4
The following have been added to the the latest version:
Versions 1.2 and earlier are no longer supported. If you are using an earlier version, please consider upgrading.
- *New grid type available: MASONRY. View sample. To use this grid system, simply add
GridType.MASONRY
to init()
:
extent.init(filePath, replaceExisting, gridType);
extent.init(filePath, replaceExisting, displayOrder, gridType);
- You can now add labels to your log events:
extent.log(LogStatus.INFO, "Example: <span class='label success'>success</span>");
extent.log(LogStatus.INFO, "Example: <span class='label failure'>fail</span>");
extent.log(LogStatus.INFO, "Example: <span class='label info'>info</span>");
extent.log(LogStatus.INFO, "Example: <span class='label warn'>warning</span>");
|
- Insert code-blocks using the
<pre>
tag:
- You can now change title for your charts using:
extent.config()
.chartTitle(Chart.TEST, "Your New Title")
.chartTitle(Chart.TEST_SET, "Your New Title");
- It is possible to change the size of images by specifying a size in percentage:
extent.config().setImageSize("30%");
Default size is 50%
.
- It is now possible to hide the caller class by this simple setting:
extent.config().displayCallerClass(false);
Owner / Developer
This library is developed and maintained by:
Contributors
Download
Download the jar from
this link.
Maven / pom.xml
Simply add the following to your pom.xml:
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>1.4</version>
</dependency>
|
You can view Extent’s pom.xml
here.
Basic Usage
ExtentReports is very simple to use. Below is some
version-specific basic usage to get you started using this library.
You can also view a Selenium test that Madhu has created with usage at his
blog.
// version 1.3+
import com.relevantcodes.extentreports.*;
public class Main {
// *REQUIRED
// put this in every class
// * Main.class will become TheClassName.class
static final ExtentReports extent = ExtentReports.get(Main.class);
public static void main(String[] args) {
extent.init("C:\\Extent.html", true);
// *REQUIRED
// startTest( testName )
// creates a toggle for the given test, adds all log events under it
extent.startTest("Main");
// log(logStatus, stepName, details)
extent.log(LogStatus.PASS, "StepName", "PASS Details");
// log(LogStatus, details)
extent.log(LogStatus.INFO, "This step shows usage of log(logStatus, details)");
// report with snapshot
// log(logStatus, stepName, details, screenCapturePath)
extent.log(LogStatus.INFO, "Image", "Image example:", "C:\\img.png");
// only report a snapshot, without status
extent.attachScreenshot("pathtoImg.png", "This step attaches a screenshot without status.");
// start other tests..
}
}
|
It is not required to call endTest() version 1.0 onwards. However, calling it at the end of run session is still recommended.
Its not required to call the init
method
before each test. Its recommended to use “init” method only once, at the
beginning of the run session to set the reporting path.
By default, the oldest test appears at the top. To
change this behavior, or to allow the latest test to appear at the top,
use the code below. Report started in one order will remain in that
order unless the report is over-written or a new report is created.
extent.init(filePath, true, DisplayOrder.BY_LATEST_TO_OLDEST);
|
Initializing Report
To initialize, simple call the init method:
init(filePath, replaceExisting)
init(filePath, overwriteExisting, DisplayOrder)
init(filePath, overwriteExisting, GridType)
init(filePath, overwriteExisting, DisplayOrder, GridType)
where:
filePath: path of the file, in .htm or .html format
overwriteExisting: (true|false)
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
report
DisplayOrder: this 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 end
GridType: 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 row
Creating step logs
It is possible to log your execution steps in 3 ways:
// log(logStatus, stepName, details)
extent.log(LogStatus.PASS, "StepName", "PASS Details");
// log(LogStatus, details) (VERSION 1.2+ only)
extent.log(LogStatus.INFO, "This step shows usage of log(logStatus, details)");
// log(logStatus, stepName, details, screenCapturePath)
extent.log(LogStatus.INFO, "Image", "Image example:", "C:\\img.png");
Appending to an existing report
Easy! Simply use
overwriteExisting = false
setting to initialize and your tests will be appended to your existing report:
extent.init("path-to-file", false);
Adding a Test Description
You can insert a
description for your test using:
// startTest(String testName, String testDescription)
extent.startTest("Test - With Description", "This description will show up under Test.");
Inserting a Snapshot
You can insert
snapshot as a link or directly into the report using:
// log(LogStatus logStatus, String stepName, String details, String screenCapturePath)
extent.log(LogStatus.INFO, "Image", "Image example:", "C:\\img.png");
Attaching a Snapshot without Status
You can attach a snapshot to the report (v1.2+) without having to specify status using:
// void attachScreenshot(path, details)
extent.attachScreenshot("pathToImg.png", "Attach screenshot without status.");
Attaching a screen-shot is not counted as a step and will not show under Execution Info either.
Using Relative paths for snapshots
Relative paths starting with “.” and “/” characters are supported:
// ./pathToImg.png
extent.log(LogStatus.INFO, "Image", "Image example:", "./pathToImg.png");
// /pathToImg.png
extent.log(LogStatus.INFO, "Image", "Image example:", "/pathToImg.png");
If you using an absolute path, “file:///” will be automatically be appended for the image to load.
Inserting a Label
You can add labels to your log events using
<span class='label labelName'>label message</span>
.
There are 4 labels available:
- success
- failure
- info
- warn
extent.log(LogStatus.INFO, "Example: <span class='label success'>success</span>");
extent.log(LogStatus.INFO, "Example: <span class='label failure'>fail</span>");
extent.log(LogStatus.INFO, "Example: <span class='label info'>info</span>");
extent.log(LogStatus.INFO, "Example: <span class='label warn'>warning</span>");
|
Inserting a Link
You can use HTML anywhere in this report. Simply do this to insert a link:
extent.log(LogStatus.PASS, "Link", "Usage: <a href='http://relevantcodes.com'>link</a>.");
|
Inserting Custom HTML
Just like above, you can insert any HTML tag to your report:
extent.log(LogStatus.INFO, "HTML", "Usage: <span style='font-weight:bold;'>BOLD</span>");
|
Customization
You can customize the report as you want. Changes can be easily made
to the overall CSS by bringing your own custom css, changes to the icons
can be made by picking your own from font-awesome etc. Below is some
basic usage to demonstrate this library’s customization.
Using custom CSS
You have options to use custom CSS directly (version 1.0+) in the document or bring in your own stylesheet.
// custom styles
String style = "p{font-size:20px;}" +
".test{background-color:#000 !important;color:#fff !important;}";
extent.config().addCustomStyles(style);
|
// custom stylesheet
extent.config().addCustomStylesheet("C:\\css.css");
Changing Report Title
It is possible to change the title of the report file (v1.2+) using:
extent.config().documentTitle("MyTestReport");
|
Themes*
ExtentReports can be heavily themed/modified to suit a layout as per
your needs. The example below shows a Cucumber like color-scheme:
String css = "#topbar { background-color: #8bb1ec; }" +
".topbar-items-right span { color: white; }" +
".menu span { color: darkgreen; }" +
".menu-item-selected span { border-bottom: 1px solid green; }" +
"#dashboard { background-color: transparent; }" +
".test { border: 1px solid lightseagreen; }" +
".description { background-color: transparent; border-left: 2px solid orange; padding: 2px 15px;}" +
".name { color: darkgreen; }" +
".extent-table { border: 1px solid #bbb; }" +
".extent-table th { background: none repeat scroll 0 0 olivedrab; color: #fff; }" +
".extent-table td { border-bottom: 1px solid #bbb; }";
extent.config().addCustomStyles(css);
The above will result in the following
output. Its a small change, but quite different from the
original.
Using custom JS
Just like having the ability to change document styles, you can also add your own custom scripts.
extent.config().insertJS("$('.test').click(function(){ alert('test clicked'); });");
|
Its possible to add/remove the Extent footer using the following configuration:
// remove the footer
extent.config().useExtentFooter(false);
// use the footer
extent.config().useExtentFooter(true);
|
Change status icons
Not a lot of people would do this, but you can choose to use your own
icons for log status (PASS, FAIL, WARNING etc.) by choosing one of the
icons from Fontawesome website:
http://fortawesome.github.io/Font-Awesome/icons/.
extent.config().statusIcon(LogStatus.PASS, "check-circle");
|
Changing the top-level summary
You can remove or add your own summary by using the following config:
extent.config().reportHeadline("My custom report summary.");
|
Change chart title
It is possible (v1.4+) to customize the chart-title text by using the following config:
extent.config()
.chartTitleText(Chart.TEST, "Your New Title")
.chartTitleText(Chart.TEST_SET, "Your New Title");
Change Screenshot size
The default screenshot size attached to the report is
50%
. It is possible to change screenshot size (v1.4+) by specifying a percentage:
extent.config().setImageSize("30%");
CallerClass display setting
It is now possible to hide the caller class by this simple setting:
extent.config().displayCallerClass(false);
Feature Requests
Think of any new features? Would you like to see this library in another language? Please drop a comment
here and let me know.
Click
here to see feature requests for upcoming version 1.2
Important version info
The below are version specific changes that you will find helpful.
Version 1.4
There are no usage changes in this version. A few new methods added, see the
whats new section for more info.
Version 1.3
There are no usage changes in this version.
Version 1.2
There are no usage changes in this version.
Version 1.1
Includes all the features added in previous versions.
- Configuration() is now deprecated, use config() instead:
// 1.0 and earlier
extent.configuration().documentHead().addCustomStyles(css);
extent.configuration().footer().useExtentFooter(false);
extent.configuration().header().introSummary("This is my new summary");;
// release 1.1
extent.config()
.addCustomStyles(css)
.useExtentFooter(false)
.reportHeadline("This is my new summary");
- introSummary(String) has been renamed to reportHeadline(String)
// 1.0 and earlier
extent.configuration().header().introSummary("This is my new summary");;
// release 1.1
extent.config().reportHeadline("This is my new summary");
Version 1.0
Includes all the features added in previous versions.
- It is no longer required to call endTest after each test. Its still
recommend to use it at the very end of run-session, but not required.
See below example:
extent.startTest("Test 1");
extent.log(LogStatus.PASS, "Step", "Details");
// no need to call endTest here, you can now just start the next test
// if you are already using endTest, you don't need to remove it or change your code
extent.startTest("Test 2");
extent.log(LogStatus.INFO, "Step", "Details");
// .. more tests
|
- scripts().insertJS(script) introduced in this version
- documentHead().addCustomStyles(styles) introduced in this version
- footer().removeExtentFooter() is deprecated in this version, utilize useExtentFooter(false) instead
- footer().addExtentFooter() is deprecated in this version, utilize useExtentFooter(true) instead
Version 0.94+
- Ability to add snapshots directly to the report using log method:
extent.log(LogStatus.INFO, "Image", "Image example:", "C:\\img.png");
|
- Ability to add description for the test when using startTest:
extent.startTest("Test - With Description", "This description will show up under Test.");
|
Great stuff sairam... Thanks Anshoo Arora
ReplyDeleteThis is one of my favorite reporting tool. You can find much more detailed information in http://relevantcodes.com/extentreports-for-selenium/.
Deletenice stuff... Good
ReplyDeletei like this reports.... really wonderful.. very easy to customize
ReplyDeleteReally awesome .. In very few sites I saw about ExtentReports ... Keep on post this kind of different stuff ... Good
ReplyDeleteExtra-ordinary reports... :)
ReplyDeleteIf i share the report with others, for failed cases it's not showing images. Can you please help?
ReplyDeleteHello
DeletePlease make sure that u send the report (xyz.htm/html) along with folder which contains image. Means its better to keep the .htm/.html file in a folder and images in the same folder and check with the path of images you have given in script , according to that you must place that folder and send it.
This will solve your issue
Deletehttp://seleniummansion.blogspot.com/2017/01/how-to-add-light-box-to-your-extent.html
thanks for sharing this blog was about html reports for selenium really very helpful
ReplyDeleteSelenium Training
I don't want step view section in my extent report, any one can help?
ReplyDeleteSamsun
ReplyDeleteNevşehir
Van
Bartın
Edirne
NBC4J
Antalya
ReplyDeleteAntep
Burdur
Sakarya
istanbul
1CKYE
Erzurum
ReplyDeleteistanbul
Ağrı
Malatya
Trabzon
LQ6
Balıkesir
ReplyDeleteBursa
Mersin
Konya
Van
SCCYE
görüntülü show
ReplyDeleteücretlishow
İPY34
https://titandijital.com.tr/
ReplyDeleteçanakkale parça eşya taşıma
kırıkkale parça eşya taşıma
erzurum parça eşya taşıma
burdur parça eşya taşıma
70K5İX
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
AXİQY1
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
4RRLLİ
3F82A
ReplyDeleteÇanakkale Lojistik
Antalya Lojistik
Bursa Şehir İçi Nakliyat
Kırıkkale Parça Eşya Taşıma
Aksaray Parça Eşya Taşıma
Nevşehir Şehirler Arası Nakliyat
Kayseri Evden Eve Nakliyat
Tunceli Parça Eşya Taşıma
Mamak Parke Ustası
73FA9
ReplyDeletebuy anapolon oxymetholone
parabolan for sale
order testosterone enanthate
buy testosterone enanthate
fat burner for sale
buy testosterone propionat
pharmacy steroids
masteron for sale
order dianabol methandienone
C2933
ReplyDeleteTekirdağ Evden Eve Nakliyat
Eskişehir Evden Eve Nakliyat
buy peptides
Kalıcı Makyaj
Çankırı Evden Eve Nakliyat
Trabzon Evden Eve Nakliyat
Kars Evden Eve Nakliyat
Artvin Evden Eve Nakliyat
buy testosterone propionat
8BBFD
ReplyDeletekırklareli canlı sohbet
görüntülü sohbet yabancı
bedava sohbet odaları
bursa mobil sohbet siteleri
kayseri sesli sohbet odası
aksaray sohbet sitesi
kütahya sohbet siteleri
van parasız görüntülü sohbet uygulamaları
bitlis mobil sohbet siteleri
A5182
ReplyDeletekırşehir telefonda kadınlarla sohbet
ığdır bedava sohbet siteleri
Bolu Görüntülü Sohbet
Tunceli Parasız Sohbet Siteleri
canlı sohbet siteleri
bitlis telefonda görüntülü sohbet
Izmir Mobil Sohbet Sitesi
kırşehir tamamen ücretsiz sohbet siteleri
canlı sohbet siteleri ücretsiz
3454B
ReplyDeleteYayladere
Kofçaz
Mazgirt
Pülmür
Pertek
Otlukbeli
Bayramören
Nazimiye
İnhisar