I am new to extent reporting. I am using Selenium Webdriver and want to use Extent reports with it.
But my code is not able to create ExtentReport object.
package com.code.draft; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import com.relevantcodes.extentreports.ExtentReports; import com.relevantcodes.extentreports.ExtentTest; import com.relevantcodes.extentreports.LogStatus; public class TestReport { ExtentReports reports; ExtentTest logger; WebDriver driver; public void start(){ reports = new ExtentReports("C:\User\Test\Report\Report.html"); //Exception at this line reports object = null driver = new FirefoxDriver(); driver.get("http://www.google.com"); logger = reports.startTest("Verify Title"); logger.log(LogStatus.INFO, "Starting Browser"); reports.endTest(logger); } public static void main(String[] args) { TestReport report = new TestReport(); report.start(); } }
The above code is giving exception as :
Exception in thread "main" java.lang.NoSuchFieldError: VERSION_2_3_23 at com.relevantcodes.extentreports.HTMLReporter.start(HTMLReporter.java:76) at com.relevantcodes.extentreports.Report.attach(Report.java:314) at com.relevantcodes.extentreports.ExtentReports.<init>(ExtentReports.java:85) at com.relevantcodes.extentreports.ExtentReports.<init>(ExtentReports.java:419) at com.code.draft.TestReport.start(TestReport.java:19) at com.code.draft.TestReport.main(TestReport.java:29)
Using the below configuration :
<dependency> <groupId>com.relevantcodes</groupId> <artifactId>extentreports</artifactId> <version>2.41.2</version> </dependency>
if anyone have idea. Please help.
Advertisement
Answer
I tested your code. It shows no exception at my end. But to get your HTML report you need to flush using reports.flush()
just before reports.endTest(logger);
.