I’m trying to make a safe wait until element is visible in SeleniumLibrary but I keep getting into a weird scenario in my RF script. Here’s the keyword I’m trying to implement:
${status} Set Variable ${False}
TRY
${kw} Register Keyword To Run On Failure None
Wait Until Element Is Visible ${locator} ${timeout}
${status} Set Variable ${True}
EXCEPT
Log Pass DEBUG
FINALLY
Register Keyword To Run On Failure ${kw}
END
Return From Keyword ${status}
But the weird thing is sometimes the line ${status} Set Variable ${True} still runs even though Wait Until Element Is Visible has failed.
I actually figured it out by experimenting. Since I’m running this Try Catch in the teardown of my tests, it will apparently run both the except and continue with the Try. I’m guessing that’s just how the Teardown block works in Robot Framework. D:
Yeah, TRY/EXCEPT doesn’t work that well in teardowns. This may be changed in the future, but the change would be backwards incompatible and we can only do it in a major version. Until that you can use the robot:stop-on-failure tag in your teardown keyword: