扩展报告/测试报告如何生成特定于浏览器的报告

时间:2017-09-13 06:23:52

标签: selenium-extent-report

目前,我正在使用selenium网格在远程pc上并行运行测试用例。我正在使用extend report生成报告。假设我在两台不同的PC上使用两个不同的浏览器运行相同的测试用例。想要在单独的文件上为两个单独的浏览器生成报告。

  

使用此代码我在远程计算机上运行自动化。

@Parameters("browser")
@BeforeMethod
public void launchbrowser(String browser) throws MalformedURLException {


    if (browser.equalsIgnoreCase("firefox")) {
        System.out.println(" Executing on FireFox");
        String Node = "http://192.168.2.105:5555/wd/hub";
        DesiredCapabilities cap = DesiredCapabilities.firefox();
        cap.setBrowserName("firefox");

        wd = new RemoteWebDriver(new URL(Node), cap);
        // Puts an Implicit wait, Will wait for 10 seconds before throwing
        // exception
        wd.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        // Launch website
        wd.navigate().to(URL);
        wd.manage().window().maximize();
    }
  

此代码生成我的扩展报告而不是testng报告。

    @BeforeTest
public void setUp() {
    // where we need to generate the report
    String fileName = new SimpleDateFormat("dd-MM-yyyy").format(new Date());
    htmlReporter = new ExtentHtmlReporter("C:/xampp/htdocs/Automation_report/files/alojamento/alojamento("+fileName+").html");

        extent = new ExtentReports();
    extent.attachReporter(htmlReporter);

    // Set our document title, theme etc..
    htmlReporter.config().setDocumentTitle("Alojamiento");
    htmlReporter.config().setReportName("Alojamiento Production Testing");

    htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
    htmlReporter.config().setTheme(Theme.DARK);

}
  

这是报告格式,实际上我上传它是因为我想说明我使用此报告的原因。使用它用于GUI

enter image description here

您能否建议我如何归档我的目标?

1 个答案:

答案 0 :(得分:1)

根据您的代码,您将在 @beforeMethod 下启动浏览器。所以你需要在相同的注释下实现你的报告。

@Parameters("browser")
@BeforeMethod
public void launchbrowser(String browser) throws MalformedURLException {
Sting fileName = new SimpleDateFormat("dd-MM-yyyy").format(new Date());
htmlReporter = new ExtentHtmlReporter("C:/xampp/htdocs/Automation_report/files/alojamento/alojamento("+fileName+").html");
        
extent = new ExtentReports();
extent.attachReporter(htmlReporter);

htmlReporter.config().setDocumentTitle("Alojamiento");
htmlReporter.config().setReportName("Alojamiento Production Testing "+browser);
        
htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
htmlReporter.config().setTheme(Theme.DARK);
            if (browser.equalsIgnoreCase("firefox")) {
                System.out.println(" Executing on FireFox");
                String Node = "http://192.168.2.105:5555/wd/hub";
                DesiredCapabilities cap = DesiredCapabilities.firefox();
                cap.setBrowserName("firefox");
        
                wd = new RemoteWebDriver(new URL(Node), cap);
                // Puts an Implicit wait, Will wait for 10 seconds before throwing
                // exception
                wd.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        
                // Launch website
                wd.navigate().to(URL);
                wd.manage().window().maximize();
            }