I am not able to generate extent report with screenshot in selenium cucumber java Please help me out

0 votes
I am facing difficulty to generate report
Aug 23, 2020 in Selenium by kanikahans
• 120 points
8,470 views

1 answer to this question.

0 votes

Hello @kanikahans,

You need to define Extent Report Object at class Level or wherever you like. And then you can use it on Failure.

  • For the Report location: Create New Folder with name Report in your project directory at root location
  • For the Screenshot location: Create New Folder with name Screenshots in your project directory at root location

Here is the Code:

//Report Initialization
ExtentHtmlReporter htmlreport = new ExtentHtmlReporter(".\\Report\\Extent Report with Screenshot.html");
ExtentReports reports = new ExtentReports();
reports.attachReporter(htmlreport);
ExtentTest testlog;

//Capture and save screenshot
File screen = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
BufferedImage img = ImageIO.read(screen);
File filetest = Paths.get(".").toAbsolutePath().normalize().toFile();
ImageIO.write(img, "png", new File(filetest + "\\Screenshots\\" + "Test.png"));

//Log Screenshot in Report
testlog.info("Details of " + "Test screenshot", MediaEntityBuilder
                .createScreenCaptureFromPath(System.getProperty("user.dir") + "\\Screenshots\\" + "Test.png").build());

//Flush Report-Mandatory, Else report will not generate.  
reports.flush();

Hope it helps you!!

Thank you!

answered Aug 24, 2020 by Niroj
• 82,840 points

Related Questions In Selenium

0 votes
1 answer
+1 vote
2 answers
+1 vote
0 answers

Hello i have written below code to verify title using POM method but i am not able to print please help me

public static void verifytitle() { String Createanewaccounttttt=driver.getTitle(); System.out.println("Title is"+Createanewaccounttttt); String excepted_title="Create ...READ MORE

Sep 24, 2020 in Selenium by Jordan
• 410 points
778 views
0 votes
1 answer

i am not able to perform this method in selenium driver.get("google")

Hi Sachin, are you getting any errors ...READ MORE

answered May 15, 2019 in Selenium by Abha
• 28,140 points
1,807 views
0 votes
1 answer

i cannot add chromedriver to my path on mac.what should i do? can you tell me full procedure? i am new to selenium.

Hello @Divya, You can refer this regarding your ...READ MORE

answered Nov 25, 2020 in Selenium by Niroj
• 82,840 points
858 views
0 votes
2 answers

How to work with blocks in Selenium?

Hello @Beks, You can simply use the jQuery each() method ...READ MORE

answered Nov 25, 2020 in Selenium by Niroj
• 82,840 points
1,783 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP