# Try Catch continuing even though there's a failure

**URL:** <https://forum.robotframework.org/t/try-catch-continuing-even-though-theres-a-failure/8247>\
**Category:** Robot Framework\
**Created:** [6 January 2025 21:28 UTC](https://forum.robotframework.org/t/try-catch-continuing-even-though-theres-a-failure/8247 "2025-01-06T21:28:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wmtan01](https://avatars.discourse-cdn.com/v4/letter/w/c37758/32.png) [@wmtan01](https://forum.robotframework.org/u/wmtan01)\
**Post date:** [6 January 2025 21:28 UTC](https://forum.robotframework.org/t/try-catch-continuing-even-though-theres-a-failure/8247/1 "2025-01-06T21:28:25Z")

</div>

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.

Here’s an example log:

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/8/82845eedcc7673bff1f79767da1496faaa5c5f4f.png)

Anybody have any idea what could be causing this weird behavior? seems to work fine sometime…

---

<div class="post-metadata">

**Author:** ![wmtan01](https://avatars.discourse-cdn.com/v4/letter/w/c37758/32.png) [@wmtan01](https://forum.robotframework.org/u/wmtan01)\
**Post date:** [6 January 2025 22:10 UTC](https://forum.robotframework.org/t/try-catch-continuing-even-though-theres-a-failure/8247/2 "2025-01-06T22:10:45Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![pekkaklarck](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/pekkaklarck/32/1019_2.png) [@pekkaklarck](https://forum.robotframework.org/u/pekkaklarck)\
**Post date:** [9 January 2025 10:06 UTC](https://forum.robotframework.org/t/try-catch-continuing-even-though-theres-a-failure/8247/3 "2025-01-09T10:06:02Z")

</div>

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:

[http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#disabling-continue-on-failure-using-tags](http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#disabling-continue-on-failure-using-tags)
