Hi,
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.
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
@unknownay
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).