How to use/configure Try Catch

I have two login methods, depending on the layout of the site.
I would like to use Try Catch so that when the first method fails, automatically go to the second.
I tried to configure it but it didn’t work, the first method fails and doesn’t go to the second.

My question is how to properly configure Try Catch?


Your second method needs to be in the Catch block. The 2nd method should be in the Try block of the sub-Try/Catch. In other words, at the top level, your process will try one thing. If it succeeds, the process moves on. If it fails, it trys the try block inside the upper-level catch block.

Now, if the second method fails, I recommend just using a Rethrow activity in the innermost Catch block to ensure that the error is escalated correctly, since you’ve exhausted the things you know you can do with your process.


Hi @Guilas

In Try part we keep sequence of activities which can cause an exception and in catch section based on different type of exception that comes from try part, we keep responses that needed to be taken care of for that exception.

But logically speaking what you are doing is not a correct approach. what i will suggest is you is keep an element exists and indicate your First login screen and based on the result put a if condition to decide which approach to follow.
Keep a unique ui element which is only available for first login method when robot runs it will check for that and element exists returns false and based on If condition the else part where you call second mechanism will be executed.

Please mark as a solution if you found this helpful :slight_smile:



Hello @Guilas,

I discovered the Pick activity yesterday. You might want to give it a try.


1 Like

What activity can I use to differentiate one layout from another?

I thought that Try Catch was used for this, that is, when you give the error in “Try” it would automatically execute “Catch”

one little precision: “If it fails and the exception is among those in Catches

Hi @Guilas

Try catch is used to handle exceptions not for a logical decision making.

Why cant you use element exists activity along with an If condition that will work perfectly fine right ?


1 Like

I followed your suggestion, but in the activity following the “IF” the following error occurs:

Digitar Nome do Painel: The target Element was not specified for this activity. You should set its Target property or use this activity inside of a scope activity (Attach Browser, Open Browser, Open Application, Attach Window, Get Active Window, Element Scope activities).

I tried to use the “Attach Window” but the error remained

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.