ParseError: mismatched tag: when using Promise To and Wait For with TRY EXCEPT AS
Found in Robot Framework 6.1.1 and 7.0.0
When placing the Wait For keyword within a TRY/EXCEPT block referring to a previous Promise To, the code block executes successfully but never creates log.html file. Instead this error is thrown:
[ ERROR ] Reading XML source '/Users/kelbystine/GitHub/RF7Test/Results/output.xml' failed: ParseError: mismatched tag: line 74, column 2
*** Settings ***
Library Browser
*** Test Cases ***
Example Test
New Page
Go To https://robotframework.org
${promise} Promise To Wait For Condition URL == https://robotframework.org/#resourc
Click button[name='go-to-Resources']
TRY
Wait For ${promise}
EXCEPT AS ${error}
Log ${error}
END
The issue is solved by formatting the code in this manner:
Example Test - Working
New Page
Go To https://robotframework.org
TRY
${promise} Promise To Wait For Condition URL == https://robotframework.org/#resourc
Click button[name='go-to-Resources']
Wait For ${promise}
EXCEPT AS ${error}
Log ${error}
END
Already communicated this with the Browser Library devs and it does not seem to be an issue on their end. Most likely a block scope issue with the ${promise} variable.
I was able to reproduce the problem and it surely looks strange. There may be a bug in Robot, but I suspect Browser is doing something strange as well. If I remove TRY/EXCEPT altogether, the test runs and log is generated, but the log looks pretty strange:
As you can see, both Click and Wait For that were used in data on the same level as Promise To are shown in the log as its child keywords. In addition to that, there's also Get Url keyword that wasn't used in the data at all.
I suspect Promise To somehow internally runs keywords so that a keyword is started (i.e. there's <kw> element in output.xml) when that keywords starts and ends (i.e. there's a closing </kw>) only at the end of Wait For. That works when running only keywords, but TRY/EXCEPT adds <try> and <branch> elements that mess the XML structure. I believe Browser devs should look this next and tell a bit about that Promise To actually does.