我需要我的范围报告(v 3.0.0)才能在页面中显示超链接。我正在尝试为以下内容注入自定义HTML,其中webSessionID是我从网页上抓取的UUID。
网址格式应为:
<a href="https://myapp.xmltravel.com/app/logs/s/OPY5Q2EV3P:6CBA845DB3E99F97931FCC9ED84711EB">OPY5Q2EV3P:6CBA845DB3E99F97931FCC9ED84711EB</a>
以下是我正在尝试的内容(请注意相关领域的代码注释):
我的代码:
public class TestBase implements Config {
protected WebDriver driver = null;
private Logger APPLICATION_LOGS = LoggerFactory.getLogger(getClass());
private static ExtentReports extent;
private static ExtentTest test;
private static ITestContext context;
private static String webSessionId;
@BeforeSuite
@Parameters({"env", "browser"})
public void beforeSuite(String env, String browser) {
String f = System.getProperty("user.dir") + "\\test-output\\FabrixExtentReport.html";
ExtentHtmlReporter h = new ExtentHtmlReporter(f);
extent = new ExtentReports();
extent.attachReporter(h);
extent.setSystemInfo("browser: ", browser);
extent.setSystemInfo("env: ", env);
String codeBlockOne = "<a href=" + "\"https://myapp.com/app/logs/s/\"";
String codeBlockTwo = "/a>";
m1 = MarkupHelper.createCodeBlock(codeBlockOne); //SET HTML OPENING
m2 = MarkupHelper.createCodeBlock(codeBlockTwo); //SET HTML CLOSING
}
@AfterMethod
public void afterMethod(ITestResult result) throws IOException {
switch (result.getStatus()) {
case ITestResult.FAILURE:
test.fail(result.getThrowable());
test.fail("Screenshot below: " + test.addScreenCaptureFromPath(takeScreenShot(result.getMethod().getMethodName())));
test.fail("WebSessionId: " + m1 + webSessionId + m2);//RELEVANT METHOD
break;
case ITestResult.SKIP:
test.skip(result.getThrowable());
break;
case ITestResult.SUCCESS:
test.pass("Passed");
break;
default:
break;
}
}
相关标签的当前输出是:
<td class='step-details'>WebSessionId:
com.aventstack.extentreports.markuputils.CodeBlock@432038ectfbweb0~FE5625464A1F6ED331FB2355BDAF8F00com.aventstack.extentreports.markuputils.CodeBlock@7daa0fbd</ td>
</tr>
答案 0 :(得分:0)
不熟悉ER,但您只是获得了Markup对象引用的字符串表示。 m1 = MarkupHelper.createCodeBlock(codeBlockOne);
m1将具有Markup
类型。尝试使用m1.getMarkup()
。