Skip to content

rebot --merge doesn't work correctly if test messages contain HTML #2548

Closed

Description

@yahman72

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

Activity

  1. pekkaklarck commented on Feb 16, 2017

    @pekkaklarck
    Member

    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?

  2. yahman72 commented on Mar 3, 2017

    @yahman72
    ContributorAuthor

    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)

    same comment/question applies to #2549

  3. pekkaklarck commented on Mar 3, 2017

    @pekkaklarck
    Member

    Test messages are primarily got from exceptions:

    if result != expected:
        raise AssertionError('*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.

  4. added this to the milestone on Mar 3, 2017
  5. yahman72 commented on Mar 3, 2017

    @yahman72
    ContributorAuthor

    oh, okay - need to think about this a bit more, first thing that comes to my mind (a bit ugly though) is:

    ex = AssertionError('We got <b>severe</b> failure!!')
    ex.html = True
    raise ex
    
  6. pekkaklarck commented on Mar 3, 2017

    @pekkaklarck
    Member

    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.

  7. yahman72 commented on Mar 6, 2017

    @yahman72
    ContributorAuthor

    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.

  8. pekkaklarck commented on Mar 6, 2017

    @pekkaklarck
    Member

    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:

       class Example(AssertionError):
           def __init__(self, message, html=False):
               if html:
                   message = '*HTML* ' + message
               AssertionError.__init__(self, message)
    • 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.

  9. yahman72 commented on Mar 6, 2017

    @yahman72
    ContributorAuthor

    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

  10. 5 remaining items

  11. pekkaklarck commented on Mar 9, 2017

    @pekkaklarck
    Member

    Sounds great! If formatting changes get complicated, better to first create a PR that just fixes the actual problem. Tests definitely are needed.

  12. added a commit that references this issue on Mar 16, 2017
    b204efb
  13. yahman72 commented on Mar 16, 2017

    @yahman72
    ContributorAuthor
  14. yahman72 commented on Jan 9, 2018

    @yahman72
    ContributorAuthor

    what's the status here? The PR seems to be still open...

  15. pekkaklarck commented on Jan 9, 2018

    @pekkaklarck
    Member

    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?

  16. yahman72 commented on Jan 9, 2018

    @yahman72
    ContributorAuthor

    yeah. I'll be there too - see you there!

  17. pekkaklarck commented on Jan 9, 2018

    @pekkaklarck
    Member

    Awesome! Hopefully we can get the PR merged already there, but at least we should have time to look at it together.

  18. 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
  19. added theissue type on Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions