Window/Browser & Activity Line Variable

Dear team,

  1. I want to check a condition if the Window/Browser is existing or not in If Condition , but i could not find the window/browser type variable.
  2. I also want to know, what if i have to print the line no, let’s say the error is on activity 10th line, while any error i want to print line no. Line Automation Anywhere & Power Automate.

Kindly help on this.

Hi @balkishan ,

use activities like:

  • Check App State (Modern Experience)
    or

  • Element Exists

  • It returns a Boolean output variable (Example: isWindowExist)

  • Use it in IF:

UiPath does not directly provide “Activity Line Number” like others.

But you can capture:

  • Activity Name
  • Workflow File Name
  • Source
  • Exception Message

using the exception object inside Try Catch.

Inside Catch block:
You can use log message or throw activity and specify inside

exception.Source
exception.Message

Hope it helps!!

what if my task/process bot is big, and having multiple activities, it could be mixed, same, different, lets say error occur in open excel , and open excel i have used multiple times in the workflow, then how will you know which open excel gave the error, if we can not print the error line number?

@balkishan

you can use check app state or element exists activities instead of using If activity.

Use Try catch activity and build your entire logic in try and in catch section you can use log message to print the error details like exception.source and message.

UiPath can not print the activity number, so you cant get the at which activity it getting failed but you can at what activity it getting failed. for that As UiPath best practice you need to give unique name for each activity while developing so that you can at what activity it getting failed.

remember you have to proivde the unique name for each actitvity based on what action it performing

Hope this helps.

@balkishan

We need to make the logs before and after of every critical steps,We need to maintain log messages for every activity to identify at which activity we got error.

And also we need to rename the activity and maintain exceptions

Hope it helps!!

I can so many exception types…why

it should be a generic type (One) which should handle all types… [Those who know AA they know better]

now am confused what to select,

@balkishan

You need to select System.exception. This can handle almost all types of application exceptions.

Or if you want to throw your own excpetion nothing but any input data missing then you can select the business exception but when you want to use this business exception you need to throw the exception in try block by uisng Throw activity.

Hope this will clarify your doubts.

Please mark it as solution if you find this helpful.
Happy Automation.

@balkishan ,

System.exception is the parent of all the exceptions.You can select that type .

It catches all the exceptions.

If your workflow has any business exceptions, You can select Business exception

Hope it helps!!

If you see, i interntioanlly gave the wrong file path to see how UiPath behave while encounter any Error.

In the Exception Type: System.Exception selected.

I gave the sequence name is Test Error , and i printed the error in the message box, it gave me so many details (I feel which doesn’t require only). The error is file path is not found, first line make sense., i don’t see my sequence name there. how will i know which seq in the workflow cause the error, if multiple open excel are there.,.

@pravallikapaluri

I don’t want to print so much, i want a generic error,
which can gave me the exact error , type, line/seq name. so it is easy to debug.

@balkishan

As you can see above image
Error specifies
Name of the workflow:Main
Trycatch name
At which sequence
and error message

Need to specify

Exception.Source decribes the source of execption where we got and Exception.message describes error message

Exception.Source+Exception.message

Hope it helps!!

Hi @pravallikapaluri

I have printed the Exception.Source, why it is priting UiPath Platform
I have printed both what you mentioned in the post. see what i got in the message box.

One more thing i want to know, let’s say you’re using Throw then only it is giving the details, using Throw in the Catch Block will prevent to continue you’re workflow.

I want to avoid using Throw and get the exception details in Logs/Message, and want to continue to run the workflow.

@balkishan

Try to follow below steps,

  • Whatever actions you built create that as separate workflow
  • in Main take Try catch in try call that workflow using invoke workflow activity.
  • In catch section use log message in that pass
    "Source: " + exception.Source + Environment.NewLine + "Message: " + exception.Message
    Now you can the exact error occured activity name and exact message..

Take a look below screenshots for your reference,
seprate Workflow that i created,

Called that sub workflow in main like below,

Hope this will help.

Thanks , this make sense, avoiding unnecessary error, giving the exact error and the activity location.