0% found this document useful (0 votes)
230 views34 pages

RPA Unit 4 DC

The document provides information about monitoring user events and creating assistant bots in robotic process automation. It discusses different types of triggers that can be used to monitor events like keyboard, mouse, and system level triggers. Examples are provided to demonstrate monitoring email activities by creating a workflow that logs into an email account, takes recipient, subject, and body as input and sends an email using robotic automation. The document also discusses handling exceptions, debugging, and logging activities in robotic process automation.

Uploaded by

yogesh nikam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
230 views34 pages

RPA Unit 4 DC

The document provides information about monitoring user events and creating assistant bots in robotic process automation. It discusses different types of triggers that can be used to monitor events like keyboard, mouse, and system level triggers. Examples are provided to demonstrate monitoring email activities by creating a workflow that logs into an email account, takes recipient, subject, and body as input and sends an email using robotic automation. The document also discusses handling exceptions, debugging, and logging activities in robotic process automation.

Uploaded by

yogesh nikam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Robotic Process

Automation

MODULE-4: Handling User Events and Assistant Bots,


Exception Handling, Debugging, and Logging

Sanjeela Sagar
[email protected]

Vidyalankar School of
Information Technology
Wadala (E), Mumbai
www.vsit.edu.in
Certificate
This is to certify that the e-book titled “Robotic Process
automation” comprises all elementary learning tools for a better
understating of the relevant concepts. This e-book is comprehensively compiled as per the
predefined eight parameters and guidelines.

Signature Date: 25-11-2023


Sanjeela Sagar
Assistant Professor
Department of IT

DISCLAIMER: The information contained in this e-book is compiled and distributed


for educational purposes only. This e-book has been designed to help learners understand
relevant concepts with a more dynamic interface. The compiler of this e-book and
Vidyalankar School of Information Technology give full and due credit to the authors of
the contents, developers and all websites from wherever information has been sourced.
We acknowledge our gratitude towards the websites YouTube, Wikipedia, and Google
search engine. No commercial benefits are being drawn from this project.
Unit 4
• Handling User Events and Assistant Bots: What are assistant bots?, Monitoring system
event triggers, Hotkey trigger, Mouse trigger, System trigger ,Monitoring image and element
triggers, An example of monitoring email, Example of monitoring a copying event and
blocking it, Launching an assistant bot on a keyboard event
• Exception Handling, Debugging, and Logging: Exception handling, Common exceptions
and ways to handle them, Logging and taking screenshots, Debugging techniques,
Collecting crash dumps, Error reporting

Recommended Books
• Learning Robotic Process Automation, Alok Mani Tripathi, Packt, 1st, 2018
• Robotic Process Automation Tools, Process Automation and their benefits: Understanding
RPA and Intelligent Automation, Srikanth Merinda, CreateSpace Independent Publishing,
1st, 2018
• The Simple Implementation Guide to Robotic Process Automation (Rpa): How to Best
Implement Rpa in an Organization, Kelly, Wibbenmeyer, iUniverse, 1st, 2018

Prerequisites and Linking


Pre-requisites Linkage
Unit IV
Sem 1 Sem VI

Robotic Process Programming Logic Project


Automation
Q.1 What are assistant bots? Explain.
Assistant Robots are front office Robots that require some user interaction. Inthis case, the
automation will run only when a certain event or user action is triggered.
Trigger events are basically commands to tell the Robot to start its automationprocess.
For example, say I want some text to be typed into the Notepad application. Inparticular, I want
the Robot to type into the Notepad once I click on the text area (clicking being the trigger
activity in this case) in the Notepad application.
Let us look at the following steps to understand more:

1. Drag and drop the Monitor events activity: Here, we drag and drop aMonitor events
activity from the Activities panel inside which the trigger events will work; otherwise it
will show you an error. The Monitor events activity looks like this:

2. Drag and drop the trigger activity of choice: In the drop trigger area,drag and drop the
trigger activity that you want.

There are a lot of trigger activities shown in the Activities panel. In thiscase, we will
choose the Click Trigger activity:
3. Create workflow inside the Monitor events activity: Now inside theEvent handler
space in the Monitor events activity, we have to createthe workflow or the set of tasks
we are required to do once the triggeractivity works. In this case, we are using the Type
into activity. Indicate the blank area of a Notepad window:

This was an overview of how assistant bots work.

Q.2 What are the different types system trigger events? Explain.
There are three system trigger events—Hotkey Trigger, Mouse Trigger,and System
Trigger:
Though all three triggers are used for triggering activities, they areused differently as
explained in the following section.

Hotkey trigger

Hotkey trigger works for shortcut keys. Suppose we want a certain workflow to work once
the user presses the Alt + F4 keys or any othershortcut key. In such a case, we will use the
Hotkey trigger:

Mouse trigger

This is used when we want to trigger events on performing a mouse action (left-click, right- click,
or middle-click) as shown in the followingscreenshot:

As shown in the screenshot, we can select the type of click with which we want to trigger
events. We can also use other special keys with mouse actions as shown.
System trigger

This is the last type of system trigger activity. A system trigger is usedto trigger events on
mouse actions, keyboard actions, or both, all of which we can select from the Properties
panel. We can also select the action to be performed, that is, forwarding the event or
blocking the event as shown in the following screenshot:

Q.3 How image and element triggers are monitored? Explain.


With an image trigger, the events will occur once the user has clickedon a certain image that
is indicated in the Click Image Trigger activity.

By clicking on Indicate element on screen, we have to select an image thatwill trigger the
event when clicked.

In the Element Trigger, there are two activities that come into play. These are
Click Trigger

and Key Press Trigger as shown in the following screenshot:

The Click trigger activity is used to trigger events when a user simply
clicks on a UI element:

The Key press trigger activity is used when we need to trigger events bypressing a certain
key or by selecting the image on the screen to trigger events:

Q.4 Give the workflow to monitor email?


Following is the workflow to monitor e-mail
1. Open the browser and browse to www.gmail.com: To do this, drag anddrop the Open
browser activity. In the required field for the address, enter www.gmail.com:

2. Getting username and password: After typing in the address, we have toask the user for a
username and password. For this, we will use the Input dialog activity as shown in the
following screenshot. We have dragged anddropped two Input dialog activities to ask the user
for a username and password respectively. Until the user types in each dialog and presses
okay, the
Robot will not work:Once the user types in the username and password, wesave these
details into two variables: user and pass. You can convert their values into a variable by
going to the Input dialog property in the Properties panel. Just right-click on the empty text
box of the Result property and chooseCreate Variable. We have named it user as shown in
the following screenshot:

3. Entering a username and password: We shall use the Type into activityto enter a username
and password by indicating the respective fields fortyping in the username and password.

Once the user enters the username and password, he needs to login which he can either do by
clicking on the login button or by pressing the Enter key on the keyboard. We will use the Send
hotkey activity to send the Enterkey (as shown in the following screenshot). By doing so, the login
button isclicked:
4. Trigger the send email event with a Hotkey trigger: Our next step isto trigger the send
mail event. Here, pressing the Enter key will be thetrigger. On pressing it, the Robot
performs the rest of the send email task. For this, we will use the Hotkey trigger activity.
We first have todrag and drop the Monitor events activity as trigger activities only work
under it:

Since we are using the Hotkey trigger, we have dropped the Hotkey trigger
activity in that area:

In the area for the Event handler, we need to give the sequence of steps for sending the
mail, which will involve several steps. For this, we have created a workflow showing all the
steps to be followed to send an email.This ranges from clicking on Compose mail to clicking
on the Send button as explained in the following steps.

5. Ask the user for the email ID of the recipient, the subject of the email, and its body: Our
next step is to ask the user for details. We willuse three Input dialogs, one for the email ID,
one for the subject, and one for the content.

As shown in the screenshot, we have used an Input dialog to obtain therecipient's email ID:

We now save the user input email ID inside a variable called лame (youcan easily create a
variable by pressing Ctrl + K inside the Output box inProperties):
In the second Input dialog, we will ask the user to input the subject for theemail:

The output, that is, the response entered by the user, is saved as a newvariable called
Subject? as shown in the following screenshot:

In the third input dialog, the user has to input the message/mail he or shewants to send:
We shall store the user output as a variable called message:

6. Type in the details: Now that we have all the details that are requiredfor sending the
mail, our next step will be to type into the required fields for sending the email. We will
use the Type Into activity for thisstep:
Drag and drop the Type into activity. Then, double-click on it and indicate the area where
you want to type the email ID. Since we havesaved the email ID as a variable, лame, we
enter this in the field provided, as shown in the following screenshot:

Our next requirement will be to indicate the area where we want to type the subject of
the mail. Since we have saved the subject as a variable, Subject, we enter this in the field
provided as shown in thefollowing screenshot:

Now you are required to indicate the area where you want to type themessage/mail as
indicated in the screenshot. Since we have saved the content of the mail to be sent as a
variable, message, we enter this in the field provided as shown in the following
screenshot:

7. Click on Send and confirm if successfully sent: Our final step is toclick on the Send
button so that the mail is sent and the process is
completed. In order to click on the Send button, we will use the Clickactivity and
indicate the Send button. Doing so enables the Robot to easily recognize where to click:

If you want, the Robot can also give a notification once the mail is sent.For this notification
we will use the Message box activity, which will display the message, message is sent, as
shown in the following screenshot. When the
message is displayed, and after the user has pressed OK, the wholeworkflow will
terminate since all of the steps have been executed:

Q.5 Give an example of monitoring a copying event and blocking it.


In this example, we have an Excel file from which we want the data tobe copied as soon as the
user presses the Enter key:

1. Drag and drop the Monitor events activity and the drop trigger activity into it: Drag
and drop the Monitor events activity. Double-click on it:

Drag and drop the Hotkey trigger activity and select the Enter key from
the drop- down list, as shown in the screenshot:

2. Drag and drop an Excel application scope inside the Event handler portion: We are
required to drop an activity under Event Handler. In our case, the activity is copying data
from Excel and pasting it. When we drag and drop the Excel application scope activity
inside the Eventhandler and double-click on it, we see that first we have to browse to the
Excel file from which we want to copy the information:

As shown in the screenshot, we have selected an Excel file whose name is movies; now we want to
copy this file's content.
3. Use the Read Range activity, extract the data and paste it into a new Excel file: Now,
inside the Do activity, drag and drop the Read Range activity to read all the data from this
Excel file. We will keep this extracted data in a variable named movies, as shown in the
screenshot:

We have read the data from the Excel file. Next, we want to keep it in a variable. For this,
just click on the Read Range activity and go to the Properties panel. Then create a variable
by pressing Ctrl + K and name itmovies:

4. Append to another Excel file: Now, since we have all the data saved, we can just drag and
drop another Excel application scope. Then we will indicate the file that we want to
append this data to. In the Do activity, just drag and drop the Append Range activity.
Select the inputas the variable we declared earlier, that is, movies as shown in the
screenshot:

5. Block the triggered event: Now, in order to block triggered events youcan select the
EVENT_BLOCK event as the event type from the properties of the trigger in the Properties
panel as shown in the following screenshot:

Q.6 How an assistant bot is launched on a keyboard event? Explain.


Let us say we want our assistant bot to start automating only when we trigger an event. For
example, the user wants his Robot to open and starttyping in the Notepad window when he
presses Alt + W. This can be achieved using the Hotkey trigger. Also, inside the Event handler,
just create or record the sequence of steps to be followed. The detailed procedure has been
explained in the following sections:

1. Drag and drop the Monitor events activity: In this step, we will justdrag and drop the
Monitor events activity into the workflow. Whenwe double-click on it, it will look like
this:
2. Drag the Hotkey trigger activity: In the next step, we will use the Hotkey trigger activity
for the user to start the automation process. Assign Alt + W to the hotkey so that, when
the user presses this hotkey,the event will be executed:

3. Open Notepad and type into it: Our final step is to record the sequence of the steps to be
performed. In this case, this is to open Notepad and then type into it. For that just use the
help of the Desktop recorder. First,we double-click on the Notepad application in the
window as shown in
the screenshot. Select the ClickType as CLICK_DOUBLE from the

Properties panel:

After that, we record the typing action and close the Notepad window. Then click on Do not
Save because you do not want to save your file. Thesequence is shown in the following
screenshot:
Q..7 How exceptions are handled?ANS:
1. Sometimes, automation program may fail to execute. To deal with suchcases, we
use exception handling activities.
2. Exception handling is a way to handle exceptions for a process that theprogram or
the procedure has failed to execute.
3. For handling exceptions in a program, the best practice considered is to usethe Try
catch activity.
4. The Try catch activity can be found in the Activities panel. By dragging anddropping
the Try catch activity into the workspace, we can handle exceptions.
5. For handling errors in the Try catch block, we can divide the whole processinto four
parts just to make it simpler:
• Drag and drop the Try catch activity
• Try block
• Catch block
• Finally block
✓ Let's build a Try catch block to handle exceptions, in following steps:
a. Drag and drop the Try catch activity: Create a blank project. Drag and dropthe
Flowchart activity into the Designer panel. Search for the Try catch activity in the
Activities panel and drag it into the Flowchart. Set it as the Start node:
b. Try: When we double-click on the Try catch activity, dragged and dropped
inside the workspace, space for the Try activity appears, as shown in thefollowing
screenshot:

Inside the Try block, we have to drop the activity we want to perform. Drop aWrite line
activity to test the working of Try Catch block, as shown in the following screenshot:
c. Catches: Inside the Catches activity, first we have to click on Add new Catch and then
click on Add Exception option, from which we have to select the type of exception. In
most cases, System.Exception is preferred.The following screenshot shows the types
of exception. There are many more exceptions which can be viewed by clicking on the
Browse for Typesoption:

i. Say the execution fails: for example, the Click activity is unableto be
executed because of the unavailability of a UI element. Insuch a case, 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. As shown in the
following screenshot, we will drop the activity in the Catches
block. To print a message, we use a Message box:

ii. When we click on Add new catch, we are asked to select the type of
exception. We have selected System.Exception. Now inside the
exception block, we have dropped a Message box activity. Entering
exception.ToString will display the error thatoccurred during execution.
d. 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. Suppose we
want to display a message to the user notifying that theprocess is complete. To make
sure that the whole Try catch activity is executed, we will just drop a Message box
activity in the area provided in the Finally block, as shown in the following screenshot:
Q.8 What are the Common exceptions and what are the ways to handlethem?

ANS:

1. Implementing exception handling enables the robot to work in everypossible


situation and tackle any exception that may arise.
2. There are some common exceptions that we usually face while working onUiPath.

a. Unavailability of UI element
i. 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. For example, if we have a variable which is dynamically changing, we can use a
wildcard sothat it can be easily found by the robot. As shown in the following
screenshot, we can edit the dynamic attribute of the selector using wildcard characters
(in our case, * ). Another way is to attach it to the live element:
b. Handling runtime exceptions
i. We may encounter runtime errors while working in UiPath. To rectify theseerrors, 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 insidethe catch
block, we can also overcome the error which we encountered before.
ii. So placing your sequence or workflow inside the Try catch activity will helpyou handle
runtime exceptions.
c. Orbit reference not set to the instant of an object
i. This type of error usually occurs when the default value required for somevariable is
not provided. In that case, we are required to give a default value to the required
variable, as shown in the following screenshot.
ii. In the empty area indicated in the following screenshot, just type thedefault
value of the variable in order to overcome this error:

d. Index was outside the bounds of an array. Index out of the range
i. This error occurs when we try to iterate array elements by an index which isout 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.
ii. To resolve this, we must check the size of the indexes of the array or thecollective
list.

e. Image not found in the provided timeout


i. 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 anchorwill work well:
ii. As shown in the preceding screenshot, when we cannot identify the imageproperly,
Indicate Anchor will help us indicate the UI element nearby so that the recorder can
identify the correct image.

f. Click Generic error - cannot use UI CONTROL API on this UI node please useUI Hardware
ELEMENTS method
i. 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).
ii. Sometimes, either SimulateClick or the SendWindowMessages may be checked. In both
cases, when an exception is thrown we just have to uncheckthe appropriate box.

Q.9 What are the types of Logging and taking screenshots?

UiPath has a multi-process architecture that offers to execute each workflow separately in the
executor. Executors are managed by UI robots. So, if any executor stops working, then the
entire process willnot be affected
1. Client logging
i. Client logs basically enable a server to record connections. These logscan be
used by content providers in various scenarios, such as to generate billing, to
trace media server usage, or to deliver suitable quality content depending on
the speed of the client's server.
ii. For client logging in UiPath, we have an NLog configuration file which makes it easy
and flexible to integrate with databases, servers, or any other NLog targets. Logging
can be configured with this NLog.config file. UiPath Studio, Robot, and workflow
execution generate log messages onthe client side:
• Messages which are produced by the workflow execution are logged with
the execution logging source. Messages produced byUiPath Studio are
logged as Studio Source and those produced byUiPath Robot are logged as
Robot logging Source.
• We can also access these logs from UiPath Studio.
iii. We can access the stored logs by clicking on Open Logs in the EXECUTE
option.
iv. By default, these Logs are saved in %Local App %\Uipath\logs:
• The automatic logging mechanism for all errors generated, including
values of variables and arguments, may be enabled inthe UiRobot.exe
config file, which is present in
C:\Users\Uername\AppData\Local\UiPath\app-17.1.6435, by setting the
Log parameter from 0 to 1 inside the <Switches> section.
• We have two activities that can be used for logging and these arethe Log
message and WriteLine activities.

2. Server logging
i. If you have configured the UiPath server, then all logs generatedby the
execution are also sent to the server.
ii. You can take a screenshot anytime by pressing Ctrl + PrtScrn.

Q.9 What are the various Debugging techniques in UiPath? Explain.


1. There are various techniques provided by UiPath Studio for debugging in order to check
whether the workflow is running successfully or to find out errors in order to rectify
them. At the top of the UiPath window, we can seevarious available methods of
debugging inside the EXECUTE block, as shown in the following screenshot:
2. As shown in the preceding screenshot, there are various techniques fordebugging.
They are:
• Setting breakpoints
• Slow step
• Highlighting
• Break
3. Setting breakpoints
i. While debugging a workflow, we can set breakpoints in between if we want to
run the program up to a specific location. This is useful when we have to stop
before an activity ends completely. In such acase, we should use a breakpoint
on the previous activity, as shownin the following screenshot:
ii. The highlighted region indicates the breakpoint since the executionstops just
after the breakpoint. In order to continue any further, wehave to click on the
Continue button on the top corner indicated bythe arrow:

iii. When we click on Step into, the relevant part will start to execute; after we
click on Step over, execution will jump to the next part, andso on.
4. Slow step
i. This is an activity in the EXECUTE block through which we can reducethe
execution speed of a particular process or activity. This way, we can identify
each and every process and keep an eye on where to find the error. In the
Output panel, all activities or steps can be viewed. The following screenshot
shows how to use the Slow step activity:

ii. As indicated by the arrow in the preceding screenshot, when we clickon Slow
step the execution time for this particular step increases.

5. Highlighting
Highlighting is used to highlight the steps we have taken during automationand to identify
each and every step in the workflow. It is very useful while debugging and its panel can be
found in the Options menu of the Execute section in the Ribbon:
6. Break
i. The Break activity is used to break a process at a certain point. Suppose we
have a sequence performing seven activities together and we want to break the
execution at a certain activity. For this, wecan use the Break activity, as shown
in the following screenshot:

ii. While debugging, an option for Break is available (indicated by the arrow in
the preceding screenshot). We can break at any point we want to. If we want
to continue any further, we just have to click onContinue, as indicated by the
arrow in the following screenshot:
iii. Or we can stop the execution at that point by clicking on the Stop
option.

Q.10 Write short note on Collecting crash dumps.

1. Collecting crash dumps basically refers to collecting information when yourUiPath


Studio crashes. We can enable and disable crash dumps. These dumps provide us with
information regarding the UiPath crash.
2. Memory dumps are of two types--full dumps and minidumps. Full dumpsprovide us
with complete information about the encountered crash whileminidumps provide us
with just the main information regarding the crash.
3. When a crash is encountered, we first have to identify the process which has crashed.
Usually, a dialog will appear on the screen indicating the nature of the crash and the
application involved. A UiPath process could crash, such as UiStudio.exe,
UIexplorer.exe,or UiLauncher.exe or the targetapplication you want to automate may
crash.
a. Enabling crash dumps
The following are the steps to enable crash dumps:
b. Disabling crash dumps
To disable crash dumps, perform the

Exercise Questions
Q.1 What are assistant bots? Explain.

Q.2 What are the different types system trigger events? Explain.

Q.3 How image and element triggers are monitored? Explain.

Q.4 Give the workflow to monitor email?

Q.5 Give an example of monitoring a copying event and blocking it.

Q.6 How an assistant bot is launched on a keyboard event? Explain.

Q.7 How exceptions are handled?

Q.8 What are the Common exceptions and what are the ways to handle them?

Q.9 What are the types of Logging and taking screenshots?

Q.10 What are the various Debugging techniques in UiPath? Explain.

Q.11 Write short note on Collecting crash dumps.

You might also like