Uipath Session 2 - Lesson 2 - Practice 1 To 5
Uipath Session 2 - Lesson 2 - Practice 1 To 5
Uipath Session 2 - Lesson 2 - Practice 1 To 5
● Starts by asking the user a mathematical question (e.g. the equation, 1 + 1 = 2) in a Message Box with
Yes/No choices and capturing the user’s answer:
Page 2 of
● Finally, closes the Notepad application.
Drag a Message Box activity below the start node. Fill in the Message property field with the mathematical
question (e.g. 1 + 1 = 2 ?).
Next, we are going to use a Sequence within this Flowchart, so find and drag a Sequence from the Activities
Panel into the Main window and double click it to view its contents.
Page 3 of
Once opened, find and drag an Open Application activity into the sequence. Now we must indicate the
application that is to be opened. There are two ways in which you can do this. The simplest way to do this is to
have Notepad opened on your desktop, click the Indicate window on screen button in the Open Application
activity, then click on the Notepad window.
An alternative way is to enter the full path of the executable file into the FileName parameter of the Open
Application activity, as shown below. The full path in this instance would be
C:\Windows\System32\notepad.exe (remember that all strings have to be placed between quotation
marks).
Page 4 of
Page 5 of
Next, find and drag a Type Into activity into the Do container of the Open Application activity. If there is a
specific area within the window where we want to type, we have to indicate the element again. However, in
this case, this is not necessary.
The next step is to add the text that is to be typed into Notepad. Within quotation marks, type Correct. Now
we have a complete sequence.
Page 6 of
Back in the main flowchart, copy and paste the previous sequence so it appears twice. Rename the sequences
to Correct Sequence and Incorrect Sequence. Open the Incorrect Sequence and change the text from Correct
to Incorrect (remember to write between quotation marks).
Finally, add a Close Application activity to close Notepad at the end of the flowchart. Again, find this activity in
the Activities Panel and drag it into your workflow, below the other activities. The application that the activity
must interact with has to be identified again, so we must follow the same steps as before. Connect both the
correct and incorrect sequences to this activity. Your finished workflow should look like this:
Page 7 of
Page 8 of
Run the workflow. You should see Notepad being opened and then Correct being typed in before the
application is closed again (you may need to click Don’t Save when the pop up appears during closing).
Please insert the automated workflow with the correct solution, as described above, so that the users can
upload directly in Studio.
● The robot picks a random number for us to guess, guided by simple hints.
● The robot should generate a random number and ask the user to guess it through an Input Dialog
activity.
● The robot will indicate if the generated number is larger or smaller than the user’s guess
Page 9 of
The first action that must be performed is creating a random number that users have to guess. Since a range
like 0-999 is perfect for this sort of game, we will create an integer variable which has a value that corresponds
with the current time in milliseconds..
● Create a variable of the Int32 type, either through the Create Variable button on the menu bar or the
Variables Panel.
○ Name the variable number.
○ After naming it, set the Type from Generic Value to Int32 in the variable type drop-down
menu.
● Set the value to DateTime.Now.Millisecond, without quotation marks.
○ This reads the current system time, and only takes the milliseconds value.
Now that there is a random number to guess, use an Input Dialog activity to prompt the user for a number.
Make the prompt dynamic, so it can change as the user guesses and reuses the guessing prompt.
● Find and insert an Input Dialog activity and drag it below the start node.
● Create a String variable called hint and give it a value similar to “Please pick a number between 1
and 999”.
○ This will be the default value. In other words, this will be the first prompt that the user will
see. When it changes, the original value will be overwritten with different prompts.
● In the Input Dialog activity, insert hint in the Label property field.
● In the Title field, enter something like “Guessing Game”.
Page 10 o
● Create another Int32 variable and name it guess, leaving the default value blank. Place this variable
name in the Output field of the Input Dialog activity.
● Here is what the variables panel should look like at this point:
This answer should lead to a decision node which evaluates if the guessed number is the correct number. If
correct, the process should display a message box notifying the user that the guess was correct. If incorrect,
the process should go to another decision node to evaluate whether the guess was too high.
● Search for and add a Flow Decision activity under the Input Dialog.
● In the Condition field, type number = guess to see if the variables have equal values.
● Search for and add a Message Box activity.
● In the Text field, write something like "Congratulations! You have guessed the number!”
Page 11 o
○ For those with previous programming experience, concatenation can be used to display the
number as well: "Congratulations! You have guessed the number "+number.ToString
+".
● Connect the True branch of the decision node to the Message Box activity.
● Search for and add a new decision node.
● Connect the False branch of the first decision node to the second decision node.
The second Flow Decision evaluates the user’s guess and displays whether the number was too high or too
low. If the guess was too high, the Assign will set the value of hint to “Try again lower.” If the guess was too
low , the Assign will set the value of hint to “Try again higher”.
● In the second decision node, insert ‘guess > number’ into the Condition field.
● Find the Assign activity and add two of them into the workflow.
○ One should assign the value “Try again lower”
○ The next should assign the value “Try again higher” to hint.
■ These activities dynamically change the prompt that the user will see.
● Connect the True branch of the decision node to the first Assign activity.
Page 12 o
● Connect the False branch of the decision node to the second Assign activity.
Make sure the prompt keeps reappearing until the user finds the correct answer.
Sequence
The first action that must be performed is creating a random number that users have to guess. Since a range
like 0-999 is perfect for this sort of game, we will create an integer variable which has a value that corresponds
with the current time in milliseconds.
Page 13 o
● Create a variable of the Int32 type, either through the Create Variable button on the menu bar or the
Variables Panel.
○ Name the variable number
○ After naming it, set the type from Generic Value to Int32 in the Variable Type drop-down
menu
● Set the value of number to DateTime.Now.Millisecond
○ This evaluates the current time and takes the value in milliseconds
Now that there is a random number to be guessed, create a new Sequence and use an Input Dialog activity to
prompt the user for a number. Make the prompt dynamic so it can change as the user guesses and reuses the
guessing prompt. This sequence will be inserted into a Do While loop later.
Page 14 o
● Create another Int32 variable, name it guess and leave the default value blank. Place this variable in
the Output field of the Input Dialog activity.
Page 15 o
● The Variables panel should look like this:
The next activity in the sequence should be an If statement that evaluates the user’s guess and displays
whether the number was too high or too low. If the guess was too high, the Assign will set the value of hint
to “Try again lower”. If the guess was too low, the Assign will set the value of hint to “Try again higher”.
Page 16 o
● The sequence should look something like this:
To make this prompt keep appearing until the right number is guessed, add a loop that only ends when the
guess equals the number. Let the user know that their guess was right when the loop ends.
● Search for and add a Do While activity and place it right above the sequence added earlier, but still
inside the Main sequence.
● Click and drag the sequence added earlier into the body of the Do While activity.
● In the Condition field of the Do While activity, enter ‘guess <> number’.
○ This evaluates if the guess is not equal to the number. If they are not equal, the loop
continues.
Page 17 o
● Search for and add a Message Box activity below the Do While loop.
● In the Text field, display the text "Congratulations! You have guessed the number!”
○ For those with previous programming experience, concatenation can be used to display the
number as well: "Congratulations! You have guessed the number "+number.ToString +".".
Page 18 o
Page 19 o
Lesson 2 - Practice 2 Answers
Please insert the automated workflow with the correct solution as described above, so that the users can
upload it directly in Studio.
● A variable called testList, of String Array type, with the value: {“apples”, “lemons”, “mangos”,
“apricots”, “pears”, “oranges”, “kiwis”, “bananas”, “lychees”, “plums”}.
● Iterate through each of the array values.
● When iterating, write lines saying “I like to eat “ before each array value in the Output Panel.
● When a value that starts with ‘k’ is reached, break the loop after writing the corresponding line.
Create a variable called testList in the scope of the sequence. Set its type to String Array and fill in the
array with the given values.
Page 20 o
● Create a variable using the Create Variable button in the top toolbar (with a type of generic value), or
using the Create Variable line in the Variables Panel.
● Name it testList.
● Change the variable Type to an Array of [T], and select String. This makes it an array of string objects.
● In the default value column, enter or copy and paste the array values: {“apples”, “lemons”, “mangos”,
“apricots”, “pears”, “oranges”, “kiwifruit”, “bananas”, “lychees”, “plums”}.
● This is what the variable should look like:
Find and create a For Each activity. For the list of items to iterate through, enter the variable testList.
Make the For Each activity write a line saying “I like to eat” that is concatenated with the item value in each
loop iteration.
Drag and drop the For Each activity after searching for it in the Activity Panel.
● Enter the string array created earlier, called testList, in the Values field of the For Each activity.
● Search for the Write Line activity in the Activities Panel and drag it into the body of the For Each
activity.
● In the Text field of the Write Line activity, write “I like to eat ” & item.ToString.
○ Make sure to include a space before the second quotation mark.
Page 21 o
○ For those unfamiliar with the notation, the & symbol concatenates the string “I like to eat “
with the string version of the current item in testList.
● This is what the workflow should look like at this point:
Run the process and navigate to the Output Panel, which should look like this:
Page 22 o
Next, evaluate if any item in testList starts with the letter ‘k’ and if it does, then break the loop.
● Search for and add an If activity below the Write Line activity.
● In the Condition field, enter the expression “item.ToString.StartsWith(“k”)”.
○ This evaluates if the current item in the list that is being looped through starts with the
character “k”.
● Find and add a Break activity into the Then branch of the If activity.
● Leave the Else branch of the If activity empty.
Run the process again. This time, the output should show every line until ‘I like to eat kiwifruit.’ Your final
workflow should resemble this:
WORKFLOW:
Page 23 o
Page 24 o
Lesson 2 - Practice 3 Answers
● Has an input variable which has a value of either “red”, “green” or “yellow”.
● Could take the value from the user with a multi choice dialogue (optional).
● Has a separate logging workflow which writes what color the stoplight is and how long it will
stay on in the Output Panel.
○ The default color in the logging workflow arguments should be “red”, to be on the
safe side.
○ It will take in two arguments, color and duration.
● Has a main workflow that will invoke the logging workflow with different arguments
depending on the color, as follows:
○ Red - 50 seconds
○ Yellow - 10 seconds
○ Green - 80 seconds
First, create the logging workflow. It should be able to take in arguments for color and duration of the
stoplight.
Page 25 o
○ Set the Direction to In and the Type to String.
○ Its default value should be red (required in the exercise text).
● Add another argument called duration.
○ Set the Direction to In and the Type to Int32.
It should also log the color and duration of the stoplight in the Output Panel.
● Find and add two Log Message activities into the main sequence.
○ If you used Write Line earlier, these are very similar. However, Log Message activities have
more versatility as they can write information lines as well as troubleshooting lines.
● For the expression of the first Log Message activity, type “The streetlights now show “ + color
○ Set the Level to Info.
● For the second Log Message, set the expression to “This color will now stay on for “ +
duration.ToString + “ seconds”.
○ Set the Level to Info.
● The completed logging workflow should resemble this:
Page 26 o
Onto the main workflow, create a new Flowchart workflow. Then, create the variable that will store the
stoplight color, as well as a Switch statement that evaluates the variable.
● Find and create a Switch activity and connect it under the Start node.
Page 27 o
○ We chose this activity as it’s especially useful for branching the workflow when there are more
than 2 possible outcomes with equal weight. Adding chained simple decision activities (or
nested if blocks in a sequence) would not be a good practice in this case.
○ In the Expression field on the Properties Panel, enter the recently created variable,
stopLightsColor.
○ Make sure the TypeArgument selection is a String type.
Now, set three different cases for the Switch statement that invoke the logging workflow with different
stoplight values.
Page 28 o
● Set the case names for the other two colors.
● This is what the completed workflow should look like:
Page 29 o
Run the workflow and check the Output tab. The output should correspond to the color red.
● Change the color by modifying the default value of the stopLightsColor variable to see what
changes.
Print to the console various operations with them and see what is the result
● A + B
● C + D
● A + C
Page 30 o
● C + A
Just create the variables and add a few Write line / Log Message / Message Box activities and try the
indicated operations.
Page 31 o
Lesson 2 - Practice 5 Answers
Page 32 o