没有获取范围报告即使没有错误提示

时间:2016-11-18 05:30:55

标签: java selenium report extent

我正在尝试生成日志和高级测试报告。所以我在Selenium Framework中使用了 ExtentReport.jar

但我能够在我的项目层次结构中提到的输出文件夹中生成报告。我不知道extentreport本身是否创建了保存这些报告的文件夹,但我仍然创建了一个新文件夹并给出该文件夹名称以保存这些报告。

我使用了以下代码:

package org.Callers;

import java.io.IOException;

import javax.mail.MessagingException;

import jxl.read.biff.BiffException;

import org.Called_Pages.ExcelLib;
import org.Called_Pages.GoogleSearch;
import org.Called_Pages.SeleniumPage;
import org.Utilities.SendMail;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;

/**
* @author Noushad
*
*/
public class GooglleSearchTest {


public static WebDriver driver=new FirefoxDriver();



@Test
public void Search() throws BiffException, IOException, MessagingException, com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException
{
    // TODO Auto-generated method stub

    String extentReportFile = "E:\\Project\\jar\\Selenium Scripts\\Hybrid_Driven\\ExtentReport\\extentReport.html";
    String extentReportImage = System.getProperty("user.dir") + "\\ExtentReport\\extentImageFile.png";


    //Create object of the extentreport and specify the report file path
    ExtentReports extent = new ExtentReports(extentReportFile, true);

    //Create object of the SendMail Class 
    SendMail email = new SendMail();

    //Start the test using the ExtentTest class object
    ExtentTest test = extent.startTest("Started the Test" , "Search the Given Test");




    /*//Create Object of extent report and specify the class name of the current class in the get method  
     report = ExtentReports.get(GooglleSearchTest.class);

    //Call the init method and specify the location where you want to save this report
    //Second parameter is set to TRUE it means it will override the report with the new one
    report.init("E:\\Project\\jar\\Selenium Scripts\\myreport.html", true);


    //Start the Test
    report.startTest("Started the Test");*/


    //Maximize the Window
    driver.manage().window().maximize();
    test.log(LogStatus.INFO,"Maximized the Window");

    //Launch the Google application
    driver.navigate().to("http://www.google.com");
    test.log(LogStatus.INFO,"Launched the Application");

    //Create the instance for the ExcelLib class 
    ExcelLib xl = new ExcelLib("E:\\Project\\jar\\Selenium\\SearchText.xls");


    //Create the instance for the Excellib class which is available in the "UTILITIES PKG"
    //Excellib excel = new Excellib("E:\\Project\\jar\\Selenium\\SearchText.xls");

    //Create Instance for the GoogleSearch Page
    GoogleSearch page = new GoogleSearch(driver);

    /*//Getiing the Cell values by iterating the ExcelSheet
    for(int rowCnt = 0;rowCnt < excel.rowcount(); rowCnt++)
    {
           page.searchtext(Excellib.readcell(Excellib.GetCell("SearchText"), rowCnt));
    }*/

    //Call the GoogleSearch Page's method
    page.searchtext(xl.GetCellValue(0, 1));
    //Log.info("Getting the text from the Excelsheet to search");
    test.log(LogStatus.INFO,"Searched the Test");

    //Create instance for the SeleniumPage
    SeleniumPage sel=new SeleniumPage(driver);

    //Call the SeleniumPage method
    sel.DocClick();
    //Log.info("Clicked on the link");
    test.log(LogStatus.INFO,"Clicked on the link");


    //Take the screenshot at runtime and specify the error image path
    test.log(LogStatus.INFO, "Error Snapshot : " + test.addScreenCapture(extentReportImage));

    //close the application 
    driver.quit();

    test.log(LogStatus.INFO, "Browser Closed");


    //close the Report
    extent.endTest(test);

    //Send the Report via Email
    email.mail();

    }

    }

请帮我解决此问题,或建议我提供其他报告,其中包括日志,报告和屏幕截图。

1 个答案:

答案 0 :(得分:0)

你还没有写任何文件来实际记录。要对文档进行实际写入,只需要刷新 -

extent.flush();