Logging an HREF without escaped “less than” in jav

2019-07-04 09:53发布

We are using selenium test triggered on a jenkins. As the attachment plugin for junit is for some reasons not working, I'd like to add html-references to screenshots of the test in the log.

The ways I tried to are:

logger.info("<a href=\"file:///" + screenshotFile.getAbsolutePath() + "\">Screenshot<a>");

System.out.println("<a href=\"file:///" + screenshotFile.getAbsolutePath() + "\">Screenshot<a>");

System.err.println("<a href=\"file:///" + screenshotFile.getAbsolutePath() + "\">Screenshot<a>");

In anyway in the output the

< is always escaped as &lt;

1条回答
ゆ 、 Hurt°
2楼-- · 2019-07-04 10:35

This is commonly occurring problem, try to wrap the string with pre element.

<pre>
 //your string
</pre>
查看更多
登录 后发表回答