TestNG 测试报告链接到失败截图
为了方便查看失败截图,可以把截图放在失败日志的后面,做成链接。
//Link Reporter.log("<a href=./img/" + jpgName + " target=_blank>Failed Screen Shot</a>", true); //Img Reporter.log("<img src=./img/" + jpgName + " /img>", true);
这样点链接,能看到截图了。
如果是ReportNG 这样只能显示字符而无法显示成链接,如果需要显示,必须做如下设置:
两者选其一
1. 设置Run->Run Configurations->(x)=Arguments, VW arguments输入-Dorg.uncommons.reportng.escape-output=off, 这个是设置Eclipse的设置
2. 代码实现, 可以通过如下代码设置关闭escape-output
private static final String ESCAPE_PROPERTY = "org.uncommons.reportng.escape-output"; System.setProperty(ESCAPE_PROPERTY, "false");