Catch invalid selector into exception message

Hello,
i’m using
Studio 2024.10.1 with
UiPath.UIAutomation.Activities: 24.10.0
UiPath.System.Activities: 24.10.3

My scenario is:
a Sequence which does several operations on a WebForm
The operations are Clicks (UiPath.UIAutomationNext.Activities.NClick), TypeInto (UiPath.UIAutomationNext.Activities.NTypeInto) and so on

I’ve surrounded all the browser operations, into a Try-Catch statement.

When one of the Web-Operations fails due the webpage changed or did not load as expected, i want to know via exception, the name (or the selector) of the activity which fails. Unfortunately now, i receive only a “generic exception” text. But when i’ve a lot of different activity in the same try-catch is very hard to find out which one is failed (2)
The missing target is displayed in the output of the Studio (1) but will be very helpfull to have it together the exception (exceptions are emailed)

Obviously i can surround any single web-operation with a try-catch, and customize the exception, but i wan’t.

Another workaround i’ve thought, is to create an UiPath.Core.UiElement, add it to each activity as “Output Element” and use it to know which one was the last successfull activity done on the WebPage

Unfortunately, i’ve tested a couple of web activity, and it seems that the TypeInto activity doesn’t return any Output element ( → UiPath.Core.UiElement remain Nothing)

Maybe i’ve to enable some additional setup/configuration?
Any suggestion?

I’m a little confused. exception.Message should give you what you want. There are also other properties of exception such as exception.Source that should give you the source activity.

In Catch block you can use the log message and write exception.source which will you give the activity name which has been failed. This will give the desired activity which has been failed during the execution.

@Devid_B

Welcome to the community

Normally if you use a try catch around sequence of activities even in exception.source the activity name is not displayed

But if you surround the try catch around invoke workflow activity in the catch you can get exception.source

Cheers