Closed mandarin77 closed 7 years ago
Here is my extent class and xml config as well:
package Utility;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver;
import com.relevantcodes.extentreports.DisplayOrder; import com.relevantcodes.extentreports.ExtentReports; import com.relevantcodes.extentreports.IExtentTestClass; import com.relevantcodes.extentreports.LogStatus;
import java.util.concurrent.TimeUnit; import java.io.File; import java.io.IOException; import java.net.URL; import java.text.DateFormat; import java.text.SimpleDateFormat;
import org.apache.commons.io.FileUtils; import org.ini4j.Config; import org.junit.; import static org.junit.Assert.; import org.openqa.selenium.; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.ie.; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.edge.EdgeDriver; import org.openqa.selenium.safari.SafariDriver; import org.testng.Reporter; import org.testng.annotations.*; import org.testng.annotations.BeforeClass; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.thoughtworks.selenium.webdriven.commands.Click; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Date; import java.util.Properties; import Utility.MKTConfigReader; import commonfunctions.GetDateinJava;
public class MKTExtentManager {
@SuppressWarnings("deprecation") public static ExtentReports Instance() {
ExtentReports extent; String Path = "./Reports/Report.html"; System.out.println(Path); extent = new ExtentReports(Path, false);
extent.loadConfig(new File("./extent-config.xml")); return extent; } public static String CaptureScreen(WebDriver driver, String ImagesPath) { TakesScreenshot oScn = (TakesScreenshot) driver; File oScnShot = oScn.getScreenshotAs(OutputType.FILE); File oDest = new File(ImagesPath+".png"); try { FileUtils.copyFile(oScnShot, oDest); } catch (IOException e) {System.out.println(e.getMessage());} return ImagesPath+".png"; } }
here is the xml config:
<?xml version="1.0" encoding="UTF-8"?>
Thanks. This is fixed now.
See #815.
https://github.com/anshooarora/extentreports-java/commit/fd879337d1fbd3d07c352fc12f852eeb0ba5125c
Thanks Anshoo. I will try the fix and let you know.
All the best,
Darin
On Mar 23, 2017, at 4:26 PM, Anshoo Arora notifications@github.com wrote:
Thanks. This is fixed now.
See #815.
fd87933
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hello Anshoo,
Is this fixed in the latest Java 2.41.2 version. If I have the global date format override set to MM-dd-yyyy the dates are messed up. If I set it to the default of yyyy-MM-dd then the dates are correct.
I also see a problem on the dashboard. I ran 3 tests that took about 33 seconds to run all 3. The Dashboard Total Time Taken (Current Run) shows: 0h 5m 39s+214ms and Total Time Taken (Overall) shows: 0h 1m 72s+206ms. Quite a bit longer than 33 seconds.
Another thing I noticed is that in my pom file I have version 2.41.2 but on the report in the top corner it says: v2.41.1.
Note: I do have DisplayOrder.NEWEST_FIRST set.
Thanks, Don
When appending to extent reports, the date/time is showing incorrectly. I am able to get the correct date/time in the most recent test run, but as a new test run comes in and appends to the report, the date/time for example will change from 2-26-2017 to 08-09-0006.
Here is a snippet of the code
package TEST; import java.util.concurrent.TimeUnit; import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.RandomStringUtils; import org.ini4j.Config; import org.junit.; import static org.junit.Assert.; import org.openqa.selenium.; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.ie.; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.edge.EdgeDriver; import org.openqa.selenium.safari.SafariDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.ITestContext; import org.testng.ITestResult; import org.testng.Reporter; import org.testng.annotations.; import org.testng.annotations.BeforeClass; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; import java.lang.String; import java.net.URL; import java.text.DateFormat; import java.text.SimpleDateFormat; import com.relevantcodes.extentreports.ExtentReports; import com.relevantcodes.extentreports.ExtentTest; import com.relevantcodes.extentreports.LogStatus; import com.thoughtworks.selenium.webdriven.commands.Click; import Utility.MKTConfigReader; import Utility.MKTExtentManager; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Calendar; import java.util.Date; import java.util.Properties; import java.util.Random; import org.seleniumhq.jetty7.util.log.Log; import java.util.UUID; import commonfunctions.; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class TEST {
}
//NEW @AfterMethod //Captures test execution information to pass through in next step public void getResult(ITestResult result) throws IOException { //Captures screenshot from failed test case and inserts into test result report if(result.getStatus()==ITestResult.FAILURE) {
String screenshotPath = GetScreenshot.capture(driver, result.getMethod().getMethodName() + "_" + "failure"+sRandStr); test.log(LogStatus.FAIL, result.getThrowable()); test.log(LogStatus.FAIL, "screenshot below: " + test.addScreenCapture(screenshotPath)); } }
@AfterClass
public void tearDown() throws Exception {
{ //Closes out QA test execution reporting for test case
extent.endTest(test); extent.flush(); extent.close(); driver.quit(); }
//Closes browser //driver.quit();
String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificationErrorString)) { fail(verificationErrorString); } } }