Issue Exception.Message | Could not find the UI element corresponding to this selector: Search failed at selector tag:The closest matches found are:

I’m working a solution and inside my code I add a try/catch sequence.
I’m trying to get the short message from the exception.

I have a dynamic selector inside a click activity (any special setup)

When the selector failed, it showed the next message:

Exception.toString :
Search Company SNNs: Could not find the UI element corresponding to this selector:
[1]

Search failed at selector tag:
[1]

The closest matches found are:
[75%]
[50%]
[50%]
[50%]
[50%]
[50%]
[50%]
[50%]
[50%]
[50%]

But when I tried to use
Exception.message.toString I hope short message but instead of short message, the uipath display a Long message (similar to use Exception.ToString)

UiPath.Core.SelectorNotFoundException: Could not find the UI element corresponding to this selector:
[1]

Search failed at selector tag:
[1]

The closest matches found are:
[75%]
[50%]
[50%]
[50%]
[50%]
[50%]
[50%]
[50%]
[50%]
[50%]
at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at UiPath.Executor.BaseRunner.EndExecute(IAsyncResult result)
at UiPath.Executor.InProcessRunner.EndExecute(IAsyncResult result)
at UiPath.Core.Activities.ExecutorInvokeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at UiPath.Executor.BaseRunner.EndExecute(IAsyncResult result)
at UiPath.Executor.InProcessRunner.EndExecute(IAsyncResult result)
at UiPath.Core.Activities.ExecutorInvokeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
UiPath.Core.SelectorNotFoundException: Could not find the UI element corresponding to this selector:
[1]

Someone kwno how I can pull only a short message?
For example: Could not find the UI element corresponding to this selector:

Thank you all,

For now, you can only use substring to get part of the message. But, why do you want to get only the first part? Thanks

Hi @gheorghestan, thank you for your response.
Currently I don’t want the full message for the error, only the short message in order to pull the problem root regarding the issue. For performance / storage issues, there are many chars to be saved in our database. At this moment I’m using a trim for 1000 chars

Or, if you need only the part listing the original selector, you can do a substring from position 0 to the position of the first occurrence of the ‘Search failed’ string. It’s a programmatic solution but will do the job well until we come up a product improvement.

Sound good! I will try that because currently I only take the first 1000 chars.
Hopefully Uipath can improve it in the next releases . Good luck!
Thank you so much @gheorghestan

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