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

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();
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.  

You can also refer this for more details:https://www.softwaretestinghelp.com/extent-reports-selenium-webdriver/

Hope it helps you!!

Thank you!

answered Aug 24, 2020 by Niroj
• 82,880 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
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,060 points
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,880 points
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,880 points