I would like to include some HTML tables as embedded error messages when a python library keyword fails. For example:
foo.robot:
*** Settings ***
Library foo.py
*** Test Cases ***
Doit
Tab
foo.py:
def tab():
html = "*HTML* "
for table in ["bar", "baz"]:
html += f"<b>Modified: {table}</b>\n"
html += "<table border=1 style='border-collapse: collapse;'>\n"
html += "<tr><th>ID<td>Name\n"
html += "<tr><td>1<td>Bob\n"
html += "<tr><td>2<td>Trev\n"
html += "</table>\n"
raise AssertionError(html)
This works but there are some nice tweaks I’d like. In the Log the html given in the assertion is repeated in the Test Message and again in the Keyword:
Also the html is repeated in the Report Message:
It’s also repeated in the console:
If there is a large amount in the Message it is truncated in the middle with [ Message content over the limit has been removed. ]
It would be nice if the error Message was a summary line, for my example something like Modified: bar, baz and then only the Keyword has he full error HTML.
For example if from python I could raise the assertion like:
def tab():
summary "Modified: "
html = "*HTML* "
for table in ["bar", "baz"]:
summary += f" {table}"
html += f"<b>Modified: {table}</b>\n"
html += "<table border=1 style='border-collapse: collapse;'>\n"
html += "<tr><th>ID<td>Name\n"
html += "<tr><td>1<td>Bob\n"
html += "<tr><td>2<td>Trev\n"
html += "</table>\n"
raise AssertionError(summary, html)