首页 > 解决方案 > 无法生成范围报告

问题描述

我正在尝试使用 JUnit 在 Selinium 中生成一个简单的范围报告。但它没有生成 html 报告,我什至一直在更改目录路径。单元测试运行正常,没有显示任何错误,只是找不到 html 文件。如果缺少某些内容,请告诉我。

pom.xml

<dependencies>
...     
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        
        <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>3.1.5</version>
</dependency>


    </dependencies>

测试类

@SpringBootTest
@RunWith(SpringRunner.class)
public class CmsAutomatApplicationTests {
    public static WebDriver driver; 
    static ExtentReports extent;
    static ExtentTest test;
    static ExtentHtmlReporter htmlReporter;
       public static final String REPORT_FILE_PATH =System.getProperty("user.dir")+"/Automation_Reports/";

    @BeforeClass
    public static void startReport(){
        extent = new ExtentReports();
        htmlReporter = new ExtentHtmlReporter("C:\\Test-Automation-Report.html");
           htmlReporter.config().setTheme(Theme.DARK);
           htmlReporter.config().setEncoding("utf-8");
           htmlReporter.config().setReportName("Automation Test Results");
           htmlReporter.config().setEncoding("utf-8");
           htmlReporter.config().setJS("$('.brand-logo').text('CMS');");
           htmlReporter.config().setTimeStampFormat("EEEE, MMMM dd, yyyy, hh:mm a '('zzz')'");
           extent.attachReporter(htmlReporter);
           extent.setSystemInfo("OS",  System.getProperty("os.name"));
           extent.setSystemInfo("Java",  System.getProperty("java.specification.version"));
           extent.setSystemInfo("User",  System.getProperty("user.name"));
    }
    @Test
    public void extentReportsDemo()
    {
        test= extent.createTest("test 1");
    System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe");
     driver = new ChromeDriver();
    driver.get("https://www.google.co.in");
    if(driver.getTitle().equals("Google"))
    {
    test.log(Status.PASS, "Navigated to the specified URL");
    }
    else
    {
    test.log(Status.FAIL, "Test Failed");
    }}
    @AfterClass
    public static void endTest()
    {driver.quit();
        extent.removeTest(test);
        extent.flush();
    }

}

标签: javaspringseleniumselenium-extent-report

解决方案


推荐阅读