Saturday, January 26, 2019

Post 2: Attaching Screenshot to failed tests in ExtentReports Version 4

In Post 1 we have learned generating the extent reports using ExtentReportsV4, in this postwe will learn about adding the screenshot to failed test cases. This will be continuation to Post 1, please go through it first then continue this.

Step 1: Update the pom.xml with Apache Commons IO dependency, as shown below. This required to copy the files.

Step 2: Now write a function in base class, that takes the screenshot and returns the path of the screenshot.

Step 3: We will call this function in @AfterMethod, this function will be invoked only when test failed.

Then using "addScreenCaptureFromPath(String path)" method of extent reports, the screenshot will be attached to the test in the extent report.

Check below, the screenshot is attached to failed test case.

#HappyLearning #HappyTesting


  1. I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article... איך בודקים איי קיו


Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...