BCSE426L-ROBOTIC PROCESS AUTOMATION
[Link] Darisini P.S.
Module-5 & 6
Event Handling & Exception Handling
Handling Events
• Event Handling
• An event occurs when some action is performed
• Types
• Element triggering event
• Image triggering event
• System triggering event
Handling Events
• Element Triggering Events
• Click Trigger
• This event occurs when a specified UI element is clicked.
• Before using the Click trigger, we have to use the Monitor Event / Trigger Scope
activity.
• Without Monitor Event / Trigger Scope, the Click trigger cannot be used.
• Double-click on Monitor Event / Trigger Scope. Drag and drop the Click trigger
inside Trigger Scope.
• Also, drag and drop the activity in the Event Handler / Sequence section of
Actions.
• //In this case, we have used the Message box activity and also specified the string
value.
• Inside the Click trigger, you have to indicate the UI element that you want to click
on.
Handling Events
• Element Triggering Events
• Keypress Trigger
• This event is similar to the Click trigger. A Key press trigger event occurs
when keystrokes have been performed on some particular UI element. It
calls the Actions when it is triggered.
• While using Key press trigger event you have to specify the key or
combination of keys.
• Indicate the UI element on which you want to perform the action.
Handling Events
• Element Triggering Events
Handling Events
• Image Triggering Events
• Click Image Trigger
• Click image trigger is used for when we click an image.
• You just have to use the Click image trigger event inside the Trigger
Scope and indicate the image.
• Upon clicking the indicted image in the Click image trigger event, the
event handler will be called.
Handling Events
• System Triggering Events
• Hotkey Trigger
• This event is raised when special keys are pressed. You have to use this
event inside the Monitor event
• Specify the special key or combination of keys. Also, provide the event
handler that will be called when the event occurs
• Mouse Trigger
• This event is fired when the mouse button is pressed.
• Use this event inside the Monitor event and specify the Mouse button:
• Either the left mouse button, middle mouse button, or the right mouse
button.
• System Trigger
• This event is used when you have to use all of the keyboard events, all of
the mouse events, or both
Handling Events
• System Triggering Events
Handling Events
• Application Triggering Events
• Trigger Scope
• Element Attribute Change Trigger
• Monitors a specific UI elements activity. Used inside Trigger Scope
• Element Attribute Change Trigger
• Monitors a specific UI elements appearance / disappearance on/ from the
screen. Used inside Trigger Scope
• Process Start Trigger
• Monitors launch of a specified windows process.
• Process End Trigger
• Monitors termination of a specified windows process.
• File Change Trigger
• Monitors changes on a specified file or folder. Event types: Created, Renamed,
Changed, Deleted.
Exception Handling
• Exception Handling
• Exception handling is a way to handle exceptions for a process that the
program or the procedure has failed to execute. For handling exceptions
in a program, the best practice considered is to use the Try catch activity.
• The Try catch activity can be found in the Activities panel. By dragging
and dropping the Try catch activity into the workspace, we can handle
exceptions
• For handling errors in the Try catch block, we can divide the whole
process into four parts just to make it simpler:
• Drag and drop the Try catch activity
• Try block
• Catch block
• Finally block
Exception Handling
• Try-Catch
Exception Handling
• Try-Catch
Exception Handling
• Catch
• Click on Add New Catch
• Click on Add Exception
• [Link] is the parent
Of all exceptions.
• If the execution fails:
• Click activity is unable to be executed because of the unavailability of a UI
element
• We can use the Catches block in order to either view the error that has occurred
or for an alternative method to be used if that particular error occurs
Exception Handling
• Finally
• When we have defined the exception for our sequence, the Finally block
will always work, regardless of whether the execution was successful or
not.
Exception Handling
• Throw
• Throw is used to explicitly throw an exception in UiPath, which can be
caught by a Try/Catch activity
• Rethrow
• Rethrow is used within a Catch block to re-throw the same exception that
was caught, preserving the original exception details. This is useful if you
wish to perform some error processing, but then propagate the error up
to the next level.
Exception Handling
• Common Exceptions
• Unavailability of UI element
• Handling runtime exceptions
• Orbit reference not set to the instant of an object
• Index was outside the bounds of an array. Index out of the
range
• Image not found in the provided timeout
• Click Generic error - cannot use UI CONTROL API on this UI
node please use UI Hardware ELEMENTS method
• Logging and taking screenshots
Exception Handling
• Common Exceptions
• Unavailability of UI element
• When working on UiPath, especially on the web, we may encounter this type of
error.
• This is because the UI element was not found due to the dynamic behavior of the
web page.
• To handle this exception, we have to make changes in the selector attributes or we
have to add new attributes to the selector so that the UI element can be easily
found.
• Handling Runtime exceptions
• To rectify these errors, one of the best practices is to use the Try catch activity,
which can be used to handle exceptions at runtime.
• By keeping an alternative inside the catch block, we can also overcome the error
which we encountered before.
Exception Handling
• Common Exceptions
• Orbit reference not set to the instant of an object
• This type of error usually occurs when the default value required for some variable
is not provided.
• In that case, we are required to give a default value to the required variable
• Index was outside the bounds of an array. Index out of the
range
• This error occurs when we try to iterate array elements by an index which is out of
range.
• This happens when we are not aware of the size of the array and we just randomly
type the index to access the element.
• To resolve this, we must check the size of the indexes of the array or the collective
list.
Exception Handling
• Common Exceptions
• Image not found in the provided timeout
• This type of exception is thrown because the image was not found.
• This may be due to a change of environment, such as resolution or theme settings.
• In this case, using some a selector attribute or indicating an anchor will work.
• Click Generic error - cannot use UI CONTROL API on this UI
node please use UI Hardware ELEMENTS method
• This type of error occurs when the environment in which we are trying to use the
Click activity does not support Simulate or Send message activity (used by us to
click the UI element).
• Sometimes, either SimulateClick or the SendWindowMessages may be checked. In
both cases, when an exception is thrown we just have to uncheck the appropriate
box.
• Logging and taking screenshots