Try catch method

Hello All,

I need to add open browser actvity & login the website in TRY & CATCH method where try part will contain open browser -> enter username -> enter password -> submit

if the above task get fail it will go to catch then close the window -> reopen the browser & again try to login. please help me out for the same. please check attached screen shot for the sametry .

1 Like

Hi @priyankamalusare

So what issue you are facing in this ??

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hello Pratik,

Please check my steps which are in screen shot. as when open browser task fail it should go to catch -> close browser -> Again try to login . but its not working like that. giving me error.

What error are you getting back ?

Can you send the error message/screenshot of the error

Hello Mzahid,

If its in catch & when window load & due to some issue submit or username is not populate on screen its showing “element not find” error.

its not throwing the exception or closing the window & reopen & try to login the tool again . can you please check my steps are correct ?

Hi @priyankamalusare

When ever your browser is going to load after that you must use Element Exists activity so that it will wait till the page gets load and after that it will perform the next step/operation …

And der in your above SS Instead of Close Window activity use Close Tab Activity

Hope this may help you to solve your issue
Mark as solution if this helps you and like it :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hello Pratik,

Thanks for your response .

Can you give me steps including where to use which activity in TRY catch . it will be great .

Hello Pratik,

Need example for the same. it will be great if you can create workflow to login website & if its get fail it will try again till get successful to login website in try catch.

Thanks & regards,
Priyanka

@priyankamalusare I would suggest you to use a Retry Scope Activity in order to Retry the Login Part. You don’t need to have the Login Part again in the Catch Block.

1 Like

Yes i tried that . but suggested that to use try catch only.

@priyankamalusare But if the Login Part Fails again in the Catch then the error Won’t be handled :sweat_smile:

hi @priyankamalusare,

The Exception type Mentioned in the BrowserOperationException - Uipath will Execute this bloack only when the exception type matched this.

2 Fixes :

  1. When you encounter the exception - Get th type of the exception - Use that type in catch

  2. Use generic Exeption type - Exception - This will catch all the Exception irrespective of the Type.

If your Workflow is to handle the login scenario - then once login fails - use a Throw activity and throw new BusinessRuleException(“Login Failed”) - In ythe Catch use Exception type as BusinessRuleException


Mukesh

2 Likes

Hi @priyankamalusare

As per requested by you i have created a workflow which will solve your issue that includes all essential steps that you want

Main.xaml (26.0 KB)
Practise Solutions for Forum.zip (97.2 KB)

Before running the workflow just do the following 2steps :-

  1. Within try catch Inside type into activity Enter Wrong username & Password
  2. Within Catch Inside type into activity Enter your correct username & Password

Hope this workflow may help you to solve your query
Mark as solution if this helps you and like it :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

Thank you so much dear :slight_smile:

Hi @priyankamalusare

Cheers
You are welcome :wink:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

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