0
我想生成的日誌和先進的測試report.So我已經使用了ExtentReport.jar在我的硒框架。沒有得到程度報告甚至沒有任何錯誤提示
但我無法在我的輸出文件夾中生成報告,這是我在項目層次結構中提到的.i不要在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();
}
}
請幫我解決這個問題或建議我一些其它報告將涵蓋的日誌,報告和屏幕截圖。
我在哪裏調用flush()。它在類的末尾? –
即使我試過extent.flush();在extent.endTest()之前;但仍然面臨同樣的問題。 –
在endTest()之後執行它 –