I have planned to customize the testNG reports. So I have used ExtentReports with the below codes.
Selenium runs properly without any issues but the report is not generated in the specified folder location.
I have added ExtentReport 2.41.2 maven dependency in my pom.xml file.
Sample Code:
public class ExtentA
{
public static ExtentReports extent;
public static ExtentTest logger;
public static WebDriver driver;
@BeforeSuite
public void config()
{
extent = new ExtentReports("E:/Automation/MyReport.html", true);
extent.loadConfig(new File("E:/Automation/extentreports-java-2.41.2/extentreports-java-2.41.2/extent-config.xml"));
}
@BeforeMethod
public void beforeMtd(Method method)
{
logger = extent.startTest("sample", "test case desc");
logger.assignAuthor("Mohan");
}
@Test
public void sample()
{
System.setProperty("webdriver.chrome.driver", "C:/selenium/drivers/chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.google.co.in");
logger.log(LogStatus.PASS, "Browser Launched successfully");
System.out.println("Browser launched");
driver.manage().window().maximize();
}
@AfterMethod
public void close()
{
driver.close();
driver.quit();
extent.endTest(logger);
}
}
Before running the test case, I have created the html file in loca, but the report is not generated.
Add extent.flush();
to the end of your close method.