I need my Extent Report (v 3.0.0) to have a hyperlink in the page. I am trying to inject the custom HTML for the following, where webSessionID is a UUID I scrape from the webpage.
The URL format should be:
<a href="https://myapp.xmltravel.com/app/logs/s/OPY5Q2EV3P:6CBA845DB3E99F97931FCC9ED84711EB">OPY5Q2EV3P:6CBA845DB3E99F97931FCC9ED84711EB</a>
Here is what I am trying (note code comments for relevant areas):
My code:
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;
}
}
Current output of the relevant tag is:
<td class='step-details'>WebSessionId:
com.aventstack.extentreports.markuputils.CodeBlock@432038ectfbweb0~FE5625464A1F6ED331FB2355BDAF8F00com.aventstack.extentreports.markuputils.CodeBlock@7daa0fbd</ td>
</tr>
Not familiar with ER but you are just getting string representation of Markup object reference.
m1 = MarkupHelper.createCodeBlock(codeBlockOne);
m1 will haveMarkup
type. Try to usem1.getMarkup()
.