0% found this document useful (0 votes)
606 views35 pages

Rpa Unit2

Details answer

Uploaded by

jiledoy752
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)
606 views35 pages

Rpa Unit2

Details answer

Uploaded by

jiledoy752
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/ 35

Robotic Process Automation 18CS745

 Now, click on the Search button beside the search box. It will also get recorded
automatically and the Trash folder will appear.
5 Click on Empty Trash now: Once you are done with clicking on the Trash action, You
can see a link showing Empty Trash now. Hover mouse on this link and it will get
highlighted, click on it to delete all the messages in the Trash folder:

6 Confirm: When you click on Empty Trash now, a confirmation dialog will appear
asking your permission for the action. Just confirm your action by clicking on the OK
button.
 In the indicate anchor wizard, we have to indicate the adjacent button, that is, the Cancel
button, so that the recorder will identify that the button is adjacent to Cancel.
 Now recording is complete, press Esc to get to the recording dialog. Click on the Save &
Exit button.
 Then, in UiPath Studio, you can see a recording sequence in the Designer panel.
 Now run it by pressing the; F5 key; it should perform the same task again. You have
created your first Robot, which empties trash from your Gmail!

Department of ISE, AIT Page 24 of 28


Robotic Process Automation 18CS745

2. Emptying Recycle Bin


We are going to automate emptying the Recycle Bin. There are various steps that are
involved. Let's map the process of how to empty the Recycle Bin:

This diagram is simpler and more detailed than in the Emptying trash in Gmail example; we need
to do exactly the same steps in order to perform this task.
 Open UiPath Studio and choose a blank project.
 Since we are working in the recorder, and since we are working on the desktop and not a
web application, we are required to choose the desktop recorder:
Start the recorder and simply perform the following steps:
1. Go to the desktop by pressing the Windows + D keys.
2. Open Recycle Bin by clicking on Recycle Bin and then pressing Enter key.
3. Click on the Manage tab of the Recycle Bin folder.
4. Click on the Empty Recycle Bin button.
5. Confirm by clicking on the Yes button in the dialog box.
6. Close the Recycle Bin folder by pressing the cross button.
7. Press the Esc key and Save & Exit the recorder.

Department of ISE, AIT Page 25 of 28


Robotic Process Automation 18CS745
Now your recording is ready to view, let's examine each step recorded:
1. Go to the desktop by pressing Windows + D keys: This step is not recorded! Never mind, it is
not needed. Please note that the recorded steps attach themselves to an application, and execute
commands for that application, so the next step (Open Recycle Bin) will be executed on the
desktop whether you are there or not.
2. Open Recycle Bin by clicking on Recycle Bin and then pressing the Enter key-We can see the
recorded step in the following screenshot:

 selecting the Recycle Bin is recorded, not the Enter key. We should manually add that
step. Search for Send hot key in the Activities window and insert it into the workflow
just below the Select item 'list Desktop' step, as shown in the following screenshot:

Department of ISE, AIT Page 26 of 28


Robotic Process Automation 18CS745

 Click on the Manage tab of the Recycle Bin folder: This is recorded as it is and so
is the fourth step, click on the Empty Recycle Bin button:

4. confirming by clicking on the Yes button on the dialog box is also recorded
Smoothly:

Department of ISE, AIT Page 27 of 28


Robotic Process Automation 18CS745
In the last step, closing the Recycle Bin folder by pressing the cross button, you may have to
indicate an anchor. Save it and press F5 to run it. You see how easy it is to record steps taken on
a computer and automate them.

Department of ISE, AIT Page 28 of 28


Robotic Process Automation 18CS745

Module-3
Sequence, Flowchart and Control Flow

3. Sequencing the workflow


Ui Path provides four types of projects:
 Sequences
 Flowcharts
 User Events
 State Machines
 A Flowchart and Sequence are mainly used for simple automation.
 User Events are beneficial for implementing front office robots.
 While State Machines are used for dealing with complex business processes.

3.1 What is a Sequence?


 A Sequence is a group of logical steps. Each step represents an action or a piece of work. A
Sequence is used for processes that happen in linear succession, that is, one after the other.
 Among the three types of projects in UiPath, Sequences are the smallest.
 In the following example, we will make a simple project that asks for the name of the user
and then displays his or her response:
1. Open Ui Path Studio and click on Blank to start a fresh project. Give it a meaningful name. On the
Designer panel, drag and drop a Flowchart activity from the Activities panel.

2. Search for Sequence in the Activities panel and then drag and drop it into the Flowchart, as shown in
the following screenshot:

Department of ISE, AIT Page 1 of 68


Robotic Process Automation 18CS745

3. Double-click on the Sequence. We now have to add the steps that we want to perform. Consider each
step as an action.
We can add many steps inside a Sequence. For the sake of simplicity, we will add
two steps:
 Ask for the username in an Input dialog
 Display the username in a Message box
4. Search for Input dialog in the Search panel of the Activities panel. Drag and drop the Input dialog
activity inside the Sequence (the Input dialog activity is a dialog box that appears with a message or a
question; in response to which the user is required to put in his or her reply):

Write the appropriate message on the Label of this Input dialog to ask for the user's name. In our case,
we have put in “What’s your name?”.
5. Drag and drop a Message box activity into the Sequence. (A Message box, as the name suggests,
displays a given text. In this case, we will use it to display the text/reply that the user has given in the
Input dialog box on being asked his/her name.)
6. Next, create a variable and give it the desired name. This variable will receive the text that the user has
entered in the Input dialog box in response to our question, that is, the user's name:

Department of ISE, AIT Page 2 of 68


Robotic Process Automation 18CS745

7. We now have to specify the Result property (in the Properties panel) of the Input dialog box.
On specifying the variable name there, it will receive the text that the user entered.
Click on the dotted icon that appears on the right side of the Result property.
Now, specify the variable name:

Department of ISE, AIT Page 3 of 68


Robotic Process Automation 18CS745
8. Specify the variable name that we have created in the Text area of the Message box (the Text area of the
Message box is used to input text that will be displayed in the Message box). We just need to connect the
Sequence to the Start icon.
This can be done by right-clicking on the Sequence activity and choosing the Set as
Start node option.
9. Hit the Run button and see the result.

3.2 Activities
 Activity represents the unit of an action. Each activity performs some action. When these
activities combine together, it becomes a process.
 Every activity resides on the Activities panel of the main Designer panel. You can search for
a particular activity and use it in your project.
 For example, when we search for browser, all the browser activities will appear in the Activities
panel, as shown in the following screenshot:

Department of ISE, AIT Page 4 of 68


Robotic Process Automation 18CS745
3.2.1 Using activities with workflows

We have seen how we can easily search for a particular activity. Now, let us see how to use
them in a workflow:
1. Search for Flowchart in the same way that we have searched for the browser activities in
the Activities panel search bar. Drag and drop the Flowchart activity inside the Designer panel.

2. The Flowchart appears in the Designer panel and we have a given Start node.
The Start node specifies where the execution begins.

3. We are ready to use different activities in our Flowchart. You can use any
activity/activities inside the Flowchart. For the sake of simplicity, let us just use a
Write line activity.

4. Drag and drop the Write line activity inside the Flowchart. Set its text property
by providing a string value. Connect this Write line activity with the Start node
by right-clicking on the Write line activity and selecting Set as Start Node.

Creating different workflows and combining them into a logical Sequence


will enhance our code quality, maintainability, reliability, and readability.

Right-click on the main Designer panel and choose Extract as Workflow:

A window will pop up asking for the name. Give it a meaningful name and click on Create.
This will be the name of your workflow:

Department of ISE, AIT Page 5 of 68


Robotic Process Automation 18CS745

We have just used activities and extracted them in a workflow. If you check the main
Designer panel, it looks like the following screenshot:

Department of ISE, AIT Page 6 of 68


Robotic Process Automation 18CS745
It automatically generates the Invoke test Workflow activity. Now, when we run the
program, it will invoke the workflow that we have extracted (double-click on the Invoke
test workflow activity to see which workflow it is going to invoke and where it is
generated).
3.1.2 What Flowcharts are and when to use them
A Flowchart is generally used for complex business processes. It provides decision-making
Facilities and can be used for both small and large projects. Here, we can add activities in
Different ways:

A Flowchart provides multiple branching logical operators to make decisions. A Flowchart


is able to run in reverse. Also, it can be used inside Sequences. A Flowchart facilitates
reusability for distinct projects. Once we create it to use in a project, it can be used for a
different but similar project.

A Flowchart's branches are set to true/false by default. However, its names can be manually
changed from the Properties panel.

Department of ISE, AIT Page 7 of 68


Robotic Process Automation 18CS745
For example, enter two numbers and check whether their sum is less than 20.

Perform the following steps:

1. First, add a Flowchart from the Activities panel into the Designer panel.
2. Add a Sequence activity within the Flowchart.
3. Take two Input dialog activities (for entering the numbers to be added) inside the Sequence activity.
4. Create the variables x and y to save the values.
5. Next, add a Message box activity to perform a mathematical operation. In our case, the sum of the two
numbers is less than 20:
x + y < 20
6. Now, add a Flow Decision activity to check the mathematical operation.
7. If true, the Flow Decision will flow toward the true branch. Otherwise, it will flow towards the false
branch.

3.3 Control flow, various types of loops, and decision making

Control flow refers to the order or the particular manner in which actions are performed in
an automation. UiPath provides numerous activities for performing the decision-making
process.
These activities, present in the Activities panel, are put into the workflow either
using the double-click method or the drag and drop method.

Different types of control flow activities are as follows:


 The Assign activity
 The Delay activity
 The Break activity
 The While activity
 The Do While activity
 The For each activity
 The If activity
 The Switch activity

Department of ISE, AIT Page 8 of 68


Robotic Process Automation 18CS745
3.3.1 The Assign activity

The Assign activity is used to designate a value to the variable.


The Assign activity can be used for different purposes, such as incrementing the value of a
variable in a loop, or using the results of a sum, difference, multiplication, or division of variables
and assigning it to another variable.

3.3.2 The Delay activity

The Delay activity, as the name suggests, is used to delay or slow down an automation by
pausing it for a defined period of time.
The workflow continues after the specified period of time. It is in the hh:mm:ss format.
This activity plays a significant role when we need a waiting period during automation,
perhaps say, a waiting period required for a particular application to open.

Example: To better understand how the Delay activity works; let us see an example of an
automation that writes two messages to the Output panel with a delay of 50 seconds.
Perform the following steps:

1. First, create a new Flowchart.

2. Add a Write line activity from the Activities panel and connect it to the Start
node.

3. Select the Write line activity. Now, type the following text into the Text box:
“Hey, what is your name”.

4. Next, add a Delay activity and connect it to the Write line activity.

5. Select the Delay activity and go to the Properties panel. In the Duration field, set
00:00:50. This is a 50-second delay between the two logged messages.

6. Take another Write line activity and connect it to the Delay activity. In the
Text field, write “My name is Andrew Ng,”:

Department of ISE, AIT Page 9 of 68


Robotic Process Automation 18CS745

7. After clicking on the Run button, the Output panel shows the message that
delays it by 50 seconds:

Department of ISE, AIT Page 10 of 68


Robotic Process Automation 18CS745

3.3.3 The Break activity

The Break activity is used to break/stop the loop at a particular point, and then continue to the
next activity according to the requirement.
It cannot be used for any other activity apart from the For each activity.
It is useful when we want to break the loop to continue to the next activity in the For each activity.

In this example, we will use the Break activity to execute only one iteration. Perform the following steps:
1. Add a Sequence activity to the Designer panel.

2.Next, add a For each activity inside the Sequence (as mentioned in the preceding
section, to use the Break activity, we need the For each activity):

Department of ISE, AIT Page 11 of 68


Robotic Process Automation 18CS745
3. Create two variables; an integer variable named Item, and an array integer
variable named X. Then, set them to the text field.

4. Now, assign a default value to the integer variable X.


5. Add a Break activity inside the body of the loop.

6. Under the For Each activity, add a Write line activity.

7. In the Write line activity, type Item to string in the text field.

8. When we click the Run button, it will display one element, as shown in the
following screenshot. This is due to the Break activity, which has stopped
execution after the first iteration:

A loop can simply be created by connecting the end of the workflow to the point where we want the
workflow to resume. The While, Do while, and For each activities mentioned among the various
control flow activities are examples of loops.

3.3.4 The While activity

The While activity is used in automation to execute a statement or process based on a


certain condition. If found true, the loop is executed; that is, the process is executed
repeatedly.
The project only exits from the loop when the condition does not hold true. This
Activity is useful while iterating through an array of elements.

In the example, we will see how an integer variable will increase from 5 to 50 in
increments of 5.Perform the following steps:

1. On a Blank project, add a Sequence activity.

2. Now, create an integer type variable X. Set its default value to 5.

3. Next, add a While activity to the Sequence.

4. In the condition field, set X<5.


Department of ISE, AIT Page 12 of 68
Robotic Process Automation 18CS745
5. Add an Assign activity to the body section of the While loop.

6. Now, go to the Properties panel of the Assign activity and type in the text field
Integer variable for value field integer X+5.

7. Drag and drop a Write line activity and specify the variable name X and apply
Tostring method on this variable:

8. Now, click the Run button. The output will display in the Output panel, as shown in the
following screenshot:

Department of ISE, AIT Page 13 of 68


Robotic Process Automation 18CS745

3.3.5 The Do while activity

The Do while activity is used in automation when it is required to execute a statement


based on the fulfillment of a certain condition.
While activity executes a statement, then checks whether the condition is fulfilled.
If the condition is not fulfilled, it exits the loop.

example to understand how the Do while activity works in automation. Take an integer variable. Starting
with this variable, we shall generate all multiples of 2, less than 20.

Perform the following steps:

1. Add a Sequence to the Designer panel.

2. Add a Do while activity from the Activities panel.

3. In the body section of the Do while activity, add an Assign activity.

4. Now, select the Assign activity. Go to the Properties panel and create an integer
variable y. Set its default value to 2.

5. Set y+2 in the value section of the Assign activity to increment the result each
time by 2 until the loop is executed.

6. Add a Write line activity inside the Assign activity.

7. In the text field of the Write line activity, type y.

8. In the condition section, set the condition y<20. The loop will continue until the
condition holds true:

Department of ISE, AIT Page 14 of 68


Robotic Process Automation 18CS745

9. On clicking the Run button, the output displayed will be as follows:

3.3.6 The For each activity

The For each activity works by iterating each element from the collection of items or list of
elements, one at a time.
In the process, it will execute all the actions that are available inside the body. Thus, it iterates
through the data and processes each piece of information separately.

Department of ISE, AIT Page 15 of 68


Robotic Process Automation 18CS745
Example, we shall use the For each activity to go through a collection of even numbers and display each
element one at a time.

Perform the following steps:

1. Start with a Blank project in UiPath.

2. Add a Sequence activity to the Designer panel.

3. Next, add a For each activity within the Sequence and create an integer type
array variable, X.

3. In the default value of the variable, put in ({2,4,6,8,10,12,14,16,18,20}).

4. Add a Write line activity to the Designer Panel (this activity is used to display
the results).

6. In the Text field of the Write line activity, type item. To string to display the output:

7. Now, run the program. You will see that each number of the array is displayed
one by one because of the use of the For each activity:

Department of ISE, AIT Page 16 of 68


Robotic Process Automation 18CS745

The If activity and the Switch activity are the Control flow's decision-making activities.

3.3.7 The If activity

The If activity consists of a statement with two conditions: true or false.


If the statement is true, then the first condition is executed; if not, the second condition is
executed.
This is useful when we have to take decisions on the basis of statements.

example that checks whether the sum of any two numbers is less than 6.
Perform the following steps:

1. Add a Flowchart from the Activities panel.

2. Add two Input dialog activities. Create two integer variables, x and y.

3. In the Properties panel, change the label name and title name of both the Input
dialog activities.

4. Now, specify these name of these two variables in the Result property of both the
Input dialog activities.

5. Now add the If activity to the Designer panel.

Department of ISE, AIT Page 17 of 68


Robotic Process Automation 18CS745

6. In the condition part, X+Y<6 check whether it is true or false. Add two Write
line activities and type “True” in one and “False” in the other:

Department of ISE, AIT Page 18 of 68


Robotic Process Automation 18CS745
7. Click the Run button to check the output. If the condition holds true then it
will show the true value; otherwise, it will show the false value, as shown in the
second screenshot (in our case, we put in the values of x and y as x and y,
respectively, thus getting a sum of 13, which is not less than 6; hence, the output
shows it as false value):

3.3.8 The Switch activity

The Switch activity can be used to make a choice.


When we have various options available and want to execute one option, we
frequently use the Switch activity.
By default, the Switch activity takes an integer argument. If we want to take a
desired argument, then we can change it from the Properties panel, from the Type
Argument list.
The Switch activity is very useful in the categorization of data according to
one's ownChoice.

Example where we have to check whether a given number is odd or even.


We know that all odd numbers, when divided by 2, leave a remainder of 1.
On the other hand, even numbers, on being divided by 2, leave a remainder of 0.
Hence, we will have two cases getting a remainder of 1 or 0.

Perform the following steps:


1. Add a Sequence activity.
2. Add an Input dialog activity inside the Sequence.
3. Now, create an integer type variable k.
4. Specify the newly created variable's name in the Result property inside the
Properties panel.
5. Add the Switch activity under the Input dialog activity.
6. In the Expression field, set k mode 2 to check whether the number is divisible by
2 or not.
7. Add a Write line activity to the Default section and type the k. To string +
“is an even number” in the text field.

Department of ISE, AIT Page 19 of 68


Robotic Process Automation 18CS745

3.4 Step-by-step example using Sequence and Flowchart

 A Sequence and a Flowchart are similar concepts.


 They are both used to contain logical steps or actions.

3.4.1 How to use a Sequence

 There may be different Sequences doing their jobs. We can easily put similar Sequences into
a workflow; each workflow represents a task.
 It is very easy to test a separate workflow alone.

 Perform the following steps:


1. Drag and drop a Flowchart onto the Designer panel. Drag and drop a Sequence
activity. Connect the Sequence activity with the Start node.
2. Double click on the Sequence activity. Drag and drop an Input dialog activity
and a Message box activity. Specify a message in the label property of the Input
dialog activity.
3. Create a variable of type String. Give it a name. Also, specify this newly created
Department of ISE, AIT Page 20 of 68
Robotic Process Automation 18CS745
variable's name in the content property of the Message box activity:
Hit the Run button or press F5 to see the result.

 We can see clearly that we have used two activities inside the Sequence that are logically
related (one for inputting the name and the other for popping it up). Here, the Sequence
contains two activities.
3.4.2 How to use a Flowchart
 A Flowchart is a container. It can contain activities inside it.
 Let us drag and drop a Message box activity inside the Flowchart. Double click on the
 Message box and type “Hello World!” in the area where the text is to be quoted. Press F5 to see the
result):

Department of ISE, AIT Page 21 of 68


Robotic Process Automation 18CS745

 So, when the program has only a few steps, we can use activities directly inside the
Flowchart.
 However, it becomes more complex when we have a large number of steps. That
is why it is necessary to arrange the related activities into Sequences and then group the
Sequences into a Flowchart.
 Example to see how to use Sequences in the Flowchart.
Perform the following steps:

1. Drag and drop two Flowchart activities on the main Flowchart. Rename them as
Send mail and Message.
 We have two different workflows.
 The Send Mail workflow will send the mail to an email address.
 The Message workflow has the message body of that email and
will ask the user for a name, message, sender, and receiver.
2. We have to implement the desired steps in both workflows. For that, we are using a Sequence inside the
Flowchart.
 Double click on the Flowchart. Drag and drop a Sequence activity inside both Flowcharts.
 Connect the Sequence to the Start node by right-clicking on the Sequence and selecting
the Set as Start node option.
3. Double click on the Sequence in the Message Flowchart.
 Drag and drop four Input dialog activities for the name, message, sender, and receiver.

Department of ISE, AIT Page 22 of 68


Robotic Process Automation 18CS745

4. Double click on the Send Mail Flowchart. Double click on the Sequence. You can
drag and drop the email activities here.
5. That's it. Now, go to the main Flowchart. Connect the Message Flowchart to
the Start node. Also, connect the Send Mail activity to the Message Flowchart:

6. Run the program and visualize it.


3.4.3 Step-by-step example using Sequence and Control flow

Department of ISE, AIT Page 23 of 68


Robotic Process Automation 18CS745
 Consider an array of names. Say we have to find out how many of them start with the letter
a.
 We will then create an automation where the number of names starting with a is counted
and the result is displayed.

 Perform the following steps:


1. Drag and drop a Flowchart activity from the Activities panel.
2. Drag and drop a Sequence activity inside the Flowchart. Connect the Sequence
to the Start node by right-clicking on the Sequence activity and selecting the Set
as Start node option.
3. Double click on the Sequence activity. Create a variable. Give it a name (in our
case, we will create an array of type string and name the variable as name). Set
the variable type to Array of [T]. When asked for the type of array, select String.
Also, initialize the array in the Default section of the variable by giving it a
default values. For example, {“john”, ”sam”, ”Andrew”, ”Anitha”}.
4. Create a variable of type integer Count for storing the result. Set the variable
type to Int32:

5.Drag and drop a For each activity inside the Sequence. Also, specify the array
name in the expression box of the For each activity. The For each activity is used
to iterate over the array. It will pick up one name from the array each time until it
reaches the end:

Department of ISE, AIT Page 24 of 68


Robotic Process Automation 18CS745

Department of ISE, AIT Page 25 of 68


Robotic Process Automation 18CS745
6.Drag and drop the If activity from the Activities panel and place it inside the For each activity at
the location where Drop activity here is mentioned.
 Specify the condition in the expression box of the If activity. The If activity is used to check
for a particular condition/expression.
 If that expression is satisfied, the Then block will be executed. Otherwise, the Else block
will be executed.
 We have specified the expression as Item.Tostring.Startswith(‘a’). This
expression specifies the name present in the item variable starts with the letter
‘a’.
 The For each activity iterates over the array, picks up one name at a time,
 and stores it as a variable, item:

7. Now, we are going to use the count variable and increment it each time a name
from an array starts with the letter a.
 we have to use the A+B Assign activity. Drag and drop the A+B Assign activity inside the If
activity.

Department of ISE, AIT Page 26 of 68


Robotic Process Automation 18CS745
 Set the To property to count(variable name) and the Value property to Count+1(to
increment its value) of the A+B Assign activity:

8.Just drag and drop a Message box activity inside the Sequence activity. Specify
the count variable in the expression box of the Message box activity. But
remember, the variable that we have created is of type Int32, so, it cannot be used
with the Message box activity without converting it to a string. To convert it to a
string, we have the ‘.tostring’ method available in UiPath Studio. Just apply
it to the variable and select ‘.tostring:

Department of ISE, AIT Page 27 of 68


Robotic Process Automation 18CS745

Hit the Run button or press F5 and see the result.


4. Data Manipulation
Data manipulation is the process of changing data whether it is adding, removing, or updating it.

4.1 Variables and scope


Before discussing variables, let us take a look at Memory and its structure:

Department of ISE, AIT Page 28 of 68


Robotic Process Automation 18CS745

Memory consists of millions of memory Cells and each memory cell stores data in the form
of 0s and 1s (binary digits).
Each cell has a unique address, and by using this address, the cell can be accessed.

When data is stored in memory, its content gets split into further smaller forms (binary
digits). As shown in the preceding diagram, 2 bytes of data consists of several memory
cells.
A variable is the name that is given to a particular chunk of memory cells or simply a block
of memory and is used to hold data.
A variable is used to store data. Data is present around us in different Types-it can be an mp3
file, text file, string, numbers, and so on.
A particular type of variable can hold only that type of data.
If there is a mismatch between the data and the variable type, then an error occurs.

Department of ISE, AIT Page 29 of 68


Robotic Process Automation 18CS745
The following table shows the type a of variable available with UiPath:

 In UiPath, we can declare a variable in the Variables section. Just give it a meaningful
name and select the appropriate type from the drop-down list.
 We can also specify the scope of a variable. The Scope is the region under which the data
has its effect or availability.
 You can choose the Scope of the variable according to your requirements; try to limit it as far
as possible.

Department of ISE, AIT Page 30 of 68

You might also like