You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rebot --merge doesn't work correctly if test messages contain HTML #2548
looks like the same root cause as in #2360 i.e. the "Re-executed test has been merged." comes before the *HTML* marker
Assume dummy.robot:
*** Settings ***
Test Teardown TcTeardown
*** Test Cases ***
TC
Fail Execution this fails
*** Keywords ***
TcTeardown
Set Test Message *HTML*<a href="http://robotframework.org/">rf</a>
Run: pybot -o o1.xml dummy.robot --> parsed as HTML in report.html pybot -R o1.xml -o o2.xml dummy.robot --> parsed as HTML in report.html rebot --merge o1.xml o2.xml --> no parsing i.e. report shows the raw HTML tags
This is definitely annoying. Shouldn't be too complicated to enhance merging logic to preserve HTML formatting. It might actually make sense to always use HTML formatting when constructing the "re-executed tests have been merged" message. The current - - - marker could be replaced with <hr> or perhaps individual messages could be put into <div>s with light borders. Interested to provide a PR?
I was thinking about this a bit: is the current approach (i.e. that *HTML* marker in the beginning) really a good one?
Looks like a workaround, any ideas why it was done like that? Instead of something more "programmatic" e.g. html=False argument? Like we have it in the Log KW i.e. def log(self, message, level='INFO', html=False, console=False, repr=False)
ifresult!=expected:
raiseAssertionError('*HTML* We got <b>severe</b> failure!!')
Do you have ideas how else could it be specified that the exception should be interpreted as HTML? Notice also that the current approach works also with Java based test libraries and over the remote library interface.
Adding an optional html=False argument to Set Test Message would be possible, but that wouldn't remove the need to handle the *HTML* prefix otherwise.
Test and suite docs (#2549) don't currently support using HTML at all. With them using html=False instead of prefix would work, but it would not allow using HTML in test data similarly as prefixing the doc with *HTML* would.
This could be done. The attribute should be named with ROBOT_ prefix, though. I fail to see how that would really be better than the current approach and, more importantly, how it would help fixing this issue.
To be honest, I have not looked at code at all but the idea would be:
raise exception with html=True
the logic handling the exceptions would need know how to handle those html=True e.g. add html attribute to the xml element in output.xml, for example <doc html="yes">some documentation</doc>
report generation logic would handle those html=true attributes in the output XML i.e. parse them as HTML
But as said, I haven't looked at the code i.e. no idea what this would mean in practice: major refactoring? backwards compatibility issues? etc.
Some comments about the possibility to specify that message is HTML using an attribute in the exception itself:
Removing the current possibility to specify that the message is HTML by prefixing it with *HTML* would be badly backwards compatible. It would be possible only with a deprecation cycle spanning multiple releases. This would only be worth the effort if the benefits would be really big.
I fail to see any benefits to in using an attribute that I need to separately set to just using raise Exception('*HTML* <b>Hi!</b>'). Turning this one-liner into three lines certainly would be inconvenient. You obviously could create your own exception that does this automatically, but you could create such custom exception already now:
Even if we would remove the support for using the *HTML* prefix and added support for custom attributes, that would do absolutely nothing to help fixing the problem with --merge and messages containing HTML. If you really want that, please submit a separate issue with use cases explaining why it would be worth the effort. This issue is about fixing --merge.
This would fix the --merge issue, because when the report generation logic handles those html=true attributes it would parse them always as HTML i.e. the original problem with the *HTML* not being anymore in the beginning would also be solved.
However this doesn't seem justifiable as it causes quite much refactoring in different components.
When sticking to the *HTML* design, then - as far as I understand - this is "just" a report-generator/parser issue: the *HTML*'s are always in the output XML --> they just need special treatment in the --merge scenario.
This shouldn't be that complicated to do, maybe just that *HTML* before the Re-executed test has been merged if one of the old messages starts with *HTML*
I could give it a go and try to come up with an PR
I haven't had time for Robot Framework coding for long time. I don't have too much time for that in general, and getting SL 3.0 out and now RoboCon are eating it. This issue is in RF 3.0.3 scope already, so as soon as I have more time for RF I'll look at this too. I hope to get 3.0.3 out fairly soon after RoboCon sprints next week. Can you by the way make it there?
changed the title [-]rebot --merge breaks the HTML parsing in test message[/-][+]`rebot --merge` doesn't work correctly if test messages contain HTML[/+]on Mar 20, 2018
Activity
pekkaklarck commentedon Feb 16, 2017
This is definitely annoying. Shouldn't be too complicated to enhance merging logic to preserve HTML formatting. It might actually make sense to always use HTML formatting when constructing the "re-executed tests have been merged" message. The current
- - -marker could be replaced with<hr>or perhaps individual messages could be put into<div>s with light borders. Interested to provide a PR?yahman72 commentedon Mar 3, 2017
I was thinking about this a bit: is the current approach (i.e. that
*HTML*marker in the beginning) really a good one?Looks like a workaround, any ideas why it was done like that? Instead of something more "programmatic" e.g.
html=Falseargument? Like we have it in theLogKW i.e.def log(self, message, level='INFO', html=False, console=False, repr=False)same comment/question applies to #2549
pekkaklarck commentedon Mar 3, 2017
Test messages are primarily got from exceptions:
Do you have ideas how else could it be specified that the exception should be interpreted as HTML? Notice also that the current approach works also with Java based test libraries and over the remote library interface.
Adding an optional
html=Falseargument toSet Test Messagewould be possible, but that wouldn't remove the need to handle the*HTML*prefix otherwise.Test and suite docs (#2549) don't currently support using HTML at all. With them using
html=Falseinstead of prefix would work, but it would not allow using HTML in test data similarly as prefixing the doc with*HTML*would.yahman72 commentedon Mar 3, 2017
oh, okay - need to think about this a bit more, first thing that comes to my mind (a bit ugly though) is:
pekkaklarck commentedon Mar 3, 2017
This could be done. The attribute should be named with
ROBOT_prefix, though. I fail to see how that would really be better than the current approach and, more importantly, how it would help fixing this issue.yahman72 commentedon Mar 6, 2017
To be honest, I have not looked at code at all but the idea would be:
html=Truehtml=Truee.g. addhtmlattribute to the xml element in output.xml, for example<doc html="yes">some documentation</doc>html=trueattributes in the output XML i.e. parse them as HTMLBut as said, I haven't looked at the code i.e. no idea what this would mean in practice: major refactoring? backwards compatibility issues? etc.
pekkaklarck commentedon Mar 6, 2017
Some comments about the possibility to specify that message is HTML using an attribute in the exception itself:
Removing the current possibility to specify that the message is HTML by prefixing it with
*HTML*would be badly backwards compatible. It would be possible only with a deprecation cycle spanning multiple releases. This would only be worth the effort if the benefits would be really big.I fail to see any benefits to in using an attribute that I need to separately set to just using
raise Exception('*HTML* <b>Hi!</b>'). Turning this one-liner into three lines certainly would be inconvenient. You obviously could create your own exception that does this automatically, but you could create such custom exception already now:Even if we would remove the support for using the
*HTML*prefix and added support for custom attributes, that would do absolutely nothing to help fixing the problem with--mergeand messages containing HTML. If you really want that, please submit a separate issue with use cases explaining why it would be worth the effort. This issue is about fixing--merge.yahman72 commentedon Mar 6, 2017
This would fix the
--mergeissue, because when the report generation logic handles thosehtml=trueattributes it would parse them always as HTML i.e. the original problem with the*HTML*not being anymore in the beginning would also be solved.However this doesn't seem justifiable as it causes quite much refactoring in different components.
When sticking to the
*HTML*design, then - as far as I understand - this is "just" a report-generator/parser issue: the*HTML*'s are always in the output XML --> they just need special treatment in the--mergescenario.This shouldn't be that complicated to do, maybe just that
*HTML*before theRe-executed test has been mergedif one of the old messages starts with*HTML*I could give it a go and try to come up with an PR
5 remaining items
pekkaklarck commentedon Mar 9, 2017
Sounds great! If formatting changes get complicated, better to first create a PR that just fixes the actual problem. Tests definitely are needed.
fixed robotframework#2548
yahman72 commentedon Mar 16, 2017
PR #2562
yahman72 commentedon Jan 9, 2018
what's the status here? The PR seems to be still open...
pekkaklarck commentedon Jan 9, 2018
I haven't had time for Robot Framework coding for long time. I don't have too much time for that in general, and getting SL 3.0 out and now RoboCon are eating it. This issue is in RF 3.0.3 scope already, so as soon as I have more time for RF I'll look at this too. I hope to get 3.0.3 out fairly soon after RoboCon sprints next week. Can you by the way make it there?
yahman72 commentedon Jan 9, 2018
yeah. I'll be there too - see you there!
pekkaklarck commentedon Jan 9, 2018
Awesome! Hopefully we can get the PR merged already there, but at least we should have time to look at it together.
[-]rebot --merge breaks the HTML parsing in test message[/-][+]`rebot --merge` doesn't work correctly if test messages contain HTML[/+]Little cleanup to "rebot --merge" code and tests.
Report/log: Styles for <hr>