How to use TryCatch-function

Hi,

I am building an automation, where I want to:

  1. The robot to click a web address from Excel cell
  2. Go to the web page and copy information from there
  3. Past the information back to the Excel
  4. Do steps 1-3 again as many times as there are rows in the Excel file.

Problem is, that in the Excel file there are web addresses, that don’t work, and the automation does not continue the work after the error. How can I get the automation to go past this?

I suppose that I could use the TryCatch-function, but I do not completely understand how that works in my case, so could someone please help me to get started with the case or maybe present a better way to get past the error?

Thank you in advance!

Hi @Iida-Maria_Ojala

In the loop you thought that web address are getting error right
You can try catch the loop and in the catch you can take system exception and just drag and drop the Continue activity that’s it.

If you use the continue activity so when there is a error in try then it will flow to the catch and if you use the continue activity then it will go for the next transaction.

Hello

Here is tutorial on the Try Catch:

Can you validate each URL in a separate For each Loop first? Then skip the rows with an invalid URL?

Cheers

Steve

Hello Lida,

In my opinion, a best practice for your case wouldn’t be to use a try-catch activity but to have some logic to verify if the webpage loaded or not:

You can use a ‘Check app state’ or ‘Element Exist’ activity to determine if the page didn’t load and therefore you will be specifically checking for that.

When you use a try-catch you will bypass the activity regardless of the error and we really don’t want that because if something else fails it would be marked as if the page didn’t load when it could be something else.

Hey @Iida-Maria_Ojala ,
You can surround the UI automation activities using Try catch and then handle the exception in the catch block
image

Also you can use check app state activity

It has an inbuilt IF condition , if the indicated target appears then normal activities
If it does not appear then refresh page/ Something else

Hope it helps you out!