extentreports-java icon indicating copy to clipboard operation
extentreports-java copied to clipboard

3.0.6Version AppendExisting mode,the second addition to the encoding of non-custom encoding

Open kelvinye-lab opened this issue 8 years ago • 14 comments

ExtentHtmlReport3.0.6, HtmlReport additional mode, combined with jmeter use, Report contains Chinese, HtmlReport configuration is as follows:

HtmlReporter.config (). SetEncoding ("gbk");
HtmlReporter.setAppendExisting (true);

The first time to generate a report, Report can be displayed correctly in Chinese, the second time additional Chinese characters garbled.

The first time to show Chinese as follows: "线程组1 1-1 May 26, 2017 11:40:55 AM 0h 0m 0s+485ms".

The second time to show Chinese as follows: "?????1 1-1 May 26, 2017 11:39:40 AM 0h 1m 15s+463ms".

kelvinye-lab avatar May 26 '17 06:05 kelvinye-lab

Hello. Can you try with this commit and let me know if it works?

https://github.com/anshooarora/extentreports-java/commit/d6bbade98ff18491b9c86bf2c2c7f544fd729abb

anshooarora avatar Jul 08 '17 18:07 anshooarora

commit d6bbade98ff18491b9c86bf2c2c7f544fd729abb Author: Anshoo Arora [email protected] Date: Sat Jul 8 14:03:07 2017 -0400

reference #885 - parse charset and apply to Jsoup document

commit b4c24a46e92d09eabfad2e09160cabcb863a07fc

I have repackaged it, but not works,the problem is the same

kelvinye-lab avatar Jul 20 '17 03:07 kelvinye-lab

Can you share a sample result.html file with me to test?

anshooarora avatar Aug 03 '17 17:08 anshooarora

Can you tell me your email address?

kelvinye-lab avatar Aug 07 '17 01:08 kelvinye-lab

Hello - please check your email for followup on this ticket, you should see my email address there.

anshooarora avatar Aug 07 '17 16:08 anshooarora

Mail has been sent, can you receive it?

kelvinye-lab avatar Aug 09 '17 01:08 kelvinye-lab

Please test with this https://github.com/anshooarora/extentreports-java/commit/6528aa9298b44d98b4415a934b87aa6c62ed094a. I am able to maintain the same charset after appendExisting. Note: I used gbk charset for my test.

anshooarora avatar Aug 11 '17 16:08 anshooarora

commit 6528aa9298b44d98b4415a934b87aa6c62ed094a Author: Anshoo Arora [email protected] Date: Fri Aug 11 12:28:36 2017 -0400

fix #885 - parsing charset issue

I have repackaged it, but not works,the problem is the same

kelvinye-lab avatar Aug 14 '17 02:08 kelvinye-lab

What is the charaset after you create the report? What is the charset after you append?

anshooarora avatar Aug 14 '17 02:08 anshooarora

private static void createExtentReports(String fileName, String isAppend) { extent = new ExtentReports(); extent.setSystemInfo("Tool", "Jmeter"); extent.attachReporter(createHtmlReporter(fileName, isAppend));

}

private static ExtentHtmlReporter createHtmlReporter(String fileName, String isAppend) { ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(fileName); htmlReporter.config().setChartVisibilityOnOpen(false); htmlReporter.config().setTestViewChartLocation(ChartLocation.BOTTOM); htmlReporter.config().setTheme(Theme.STANDARD); htmlReporter.config().setEncoding("gbk"); htmlReporter.config().setReportName("Jmeter Interface Testing"); htmlReporter.config().setDocumentTitle("Interface Testing"); htmlReporter.setAppendExisting(Boolean.valueOf(isAppend));

    return htmlReporter;
}

It's all GBK

kelvinye-lab avatar Aug 15 '17 01:08 kelvinye-lab

What is the charset after append? Does it revwrt to utf-8?

anshooarora avatar Aug 15 '17 01:08 anshooarora

GBK,after append also GBK first displayed “中文乱码question8851”,after append displayed “????????question885”

kelvinye-lab avatar Aug 16 '17 01:08 kelvinye-lab

Where can I get the extenterpports debug log file? or How to output the log to the specified location

kelvinye-lab avatar Aug 25 '17 02:08 kelvinye-lab

I know how to solve the problem, The first step to the java System property "file.encoding" = utf-8, The second step is to set the code htmlReporter.config (). SetEncoding ("UTF-8"); The third step is to modify the source code of version 3.1.2, the code is as follows:

Writer.java
public synchronized void write (final File file, String text, String charset) {
         System.out.println (charset);
         try (BufferedWriter writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (file), charset))) {
             writer.write (text);
         }
         catch (Exception e) {
             logger.log (Level.SEVERE, file.getPath (), e);
         }
     }


ExtentHtmlReporter.java
... flush () {
...
     Writer.getInstance (). Write (new File (filePath), extentSource, userConfig.getEncoding ());

}

Set the font encoding but also the synchronization file encoding format, and then no problem.

kelvinye-lab avatar Dec 04 '17 08:12 kelvinye-lab