首页 文章

在Selenium testNG中不生成ExtentReport

提问于
浏览
0

我计划自定义testNG报告 . 所以我使用ExtentReports和下面的代码 .

Selenium正常运行没有任何问题,但报告未在指定的文件夹位置生成 .

我在我的pom.xml文件中添加了 ExtentReport 2.41.2 maven依赖项 .

示例代码:

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);
     }
}

在运行测试用例之前,我已在loca中创建了html文件,但未生成报告 .

1 回答

  • 1

    extent.flush(); 添加到close方法的末尾 .

相关问题