0% found this document useful (0 votes)
35 views

Robotic Process Automation

Uploaded by

harsh3112a
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Robotic Process Automation

Uploaded by

harsh3112a
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

21CS744 ROBOTIC PROCESS AND AUTOMATION

Assignment - I

Name: Harsh Abhishek


USN: 1AM21CS067
Semester: 7th
Section: A

1: Using UiPath Studio, you must read from or write to excel file. The file might be locked, missing, or
corrupted, causing errors. How would you handle errors when trying to read data from an Excel file?
Steps:
To handle errors when reading data from an Excel file using UiPath Studio, we can use a Try-Catch block.
1. Create a Sequence:
o Start by creating a new Sequence activity in UiPath Studio.
2. Add Excel Application Scope:
o Drag and drop the Excel Application Scope activity into the sequence.
o Specify the file path of the Excel file in the Workbook Path property.

3. Add a Read Range Activity:


o Inside the Excel Application Scope, drag the Read Range activity (from Workbook or Excel
activities, depending on your use case).
o Configure the range and specify the output variable (e.g., DataTable).
o Drag the Output Data Table as Text Activity followed by Message Box to view the sheet data.
4. Wrap in Try-Catch:
o Enclose the Excel Application Scope (or Read Range activity) in a Try-Catch block:
 Drag a Try-Catch activity from the activities panel.
 Place the Excel-related activities inside the Try block.
5. Handle Exceptions in Catch Block:
o In the Catch block:
 Select Exception as the type of exception to catch.
 Drag a Log Message activity or Write Line to log the error.
Example: Log "Error encountered: " + exception.Message.

Explanation:
To handle errors while reading an Excel file in UiPath, we can use a Try-Catch block to ensure robust error
handling. By enclosing the activities related to reading Excel files (such as Excel Application Scope and Read
Range) within the Try block, any exceptions like locked files, missing files, or corrupted files are gracefully
caught. The Catch block logs or displays the error message using activities like Log Message or Write Line,
ensuring the workflow does not crash. For example, if the file is locked, the error message might indicate that
the file is in use by another process; if the file is missing, the message will indicate the file could not be found.
This approach ensures smooth workflow execution by providing informative error messages while maintaining
the ability to handle exceptions dynamically, such as by implementing retry mechanisms for transient issues.
Output:
2: Use UiPath Studio to read payroll details for employees in an Excel file. You need to calculate the salary
for each employee based on attendance. Use Read Range to extract employee payroll data. Apply
calculations(eg., salary) Write the updated data into a new Excel file
Steps
1. Create a Sequence:
o Start by creating a new Sequence activity in UiPath Studio.
2. Read Payroll Data:
o Add an Excel Application Scope activity and set the file path for the payroll Excel file.
o Inside the scope, use a Read Range activity to read the payroll data (e.g., from Sheet1) into a
DataTable variable (e.g., test.xlsx).

3. Add a Salary Column (If Not Present):


o Use the Add Data Column activity to add a new column named "Salary" to the DataTable if
it doesn't already exist.
4. Calculate Salary Using For Each Row:
o Drag a For Each Row in Data Table activity into the sequence to iterate through the DataTable.
o Inside the loop, retrieve the Attendance column value for each row using
row("Attendance").ToString.
o Multiply the attendance value by the daily wage rate (e.g., 100) and assign the result to the
Salary column using an Assign activity:
 row("Salary") = CDbl(row("Attendance").ToString) * 100.
5. Write Updated Data to a New Excel File:
o Add another Excel Application Scope activity for the output file (e.g., UpdatedPayroll.xlsx).
o Use a Write Range activity inside this scope to write the updated DataTable to the new Excel
file.
Output:

3: Use OCR to digitize handwritten essays or assignments and convert them into editable text.
Steps
1. Prepare the Input:
o Take a clear picture of the handwritten assignment or essay and save it as an image file (e.g.,
.jpg or .png).
2. Create a Sequence:
o Start by creating a new Sequence activity in UiPath Studio.
3. Load the Image:
o Drag the Load Image activity into the sequence and select the image file from your computer.

4. Use OCR
o Drag the Google Cloud Vision OCR activity into the sequence.
o Configure the ApiKey (from Google Cloud Console) and specify the Output Path Variable..

5. Write to a Google Document:


o Use the Write Text activity from Google Workspace Docs and select the target document.
o Inside the text, use the extractedText variable and set the location to the beginning of the
document.
Output:

4: Using mouse activity do following to fill the form:


o Mouse Actions click: Click on input fields to type data
o Hover: Hover over dropdown
o Double-click: Double-click submit button after filling
o Use keyboard activity
o Use typeinfo for typing username
o Use secure text to type password.
Steps
1. Create a Sequence:
o Start with a new Sequence activity to organize your workflow.
2. Start a Browser Activity:
o Drag and Drop the Use Application/Browser activity and use the Indicate option to select
Chrome Browser.
3. Mouse Click on Input Fields:
o Use the Click activity to click on the username input field.
o Set the target to the specific input field using selectors or UI Explorer.

4. Keyboard Activity for Username:


o Use the Type Into activity to type the username into the clicked field.
o Set the text to the desired id (e.g., "dmk") in the properties panel.

5. Secure Text for Password:


o Use the Type Secure Text activity to securely input the password.
o Store the password in a SecureString variable and link it to this activity.
6. Hover Over Dropdown:
o Use the Hover activity to move the mouse pointer over the dropdown menu.
o Set the target to the dropdown element using selectors.

7. Double-Click Submit Button:


o Use the Double Click activity to double-click the submit button after all fields are filled.
o Ensure accurate targeting with robust selectors.

Output:
5: Given an array of integers. Illustrate step by step example using uipath that count total number of odd
elements and even elements in the array and display the count in output panel.
Steps
1. Create a Sequence:
o Start by creating a new Sequence activity in UiPath Studio.
2. Declare Variables:
o Create a variable named numbers of type Array of Int32 to hold the array of integers and add
an array of numbers as its default value.
o Create two variables: oddCount and evenCount of type Int32 and initialize both to 0.

4. Add a For Each Loop:


o Drag a For Each activity into the sequence.
o Set the For Each Item property to iterate through the numbers array.
o Rename the iteration variable to num (current integer).

5. Add an If Condition:
o Inside the For Each loop, drag an If activity to check if the number is odd or even:
 Condition: num Mod 2 = 0
6. Increment Even Count:
o In the Then section of the If condition, use an Assign activity to increment the evenCount:
 evenCount = evenCount + 1
7. Increment Odd Count:
o In the Else section, use an Assign activity to increment the oddCount:
 oddCount = oddCount + 1

8. Display Final Counts:


o After the For Each loop, use two Write Line activities to display the results in the Output panel:
o Write Line: "Even Count: " + evenCount.ToString
o Write Line: "Odd Count: " + oddCount.ToString

9. Run the Workflow:


o Execute the workflow to see the count of odd and even elements displayed in the Output
panel.
Output:

6: Trigger: Ctrl + S key press. Action: Use Send Hotkey activity to press Enter on the Save dialog or provide
a path to save the file.
Steps
1. Create a Sequence:
o Start by creating a new Sequence activity in UiPath Studio.
2. Send Ctrl + S Hotkey:
o Drag and drop the Send Hotkey activity into the sequence.
o Set the Key property to "S" and in the Modifiers property, set it to "Ctrl" to simulate Ctrl + S.
Example:
o Key: S
o Modifiers: Ctrl

3. Wait for Save Dialog (Optional):


o Optionally, add a Delay or Wait For Element activity to ensure the Save dialog has loaded
fully before proceeding.

4. Type File Path (Optional):


o If you want to specify a location to save the file, add a Type Into activity.
o Set the Selector property to target the file name or Save As text field.
o Provide the desired file path and name (e.g., "C:\Users\Example\Documents\file_name.txt").
5. Send Enter Key to Confirm Save:
o After setting the path (if applicable), use another Send Hotkey activity to press Enter and
confirm the save.
o Set the Key property to "Enter".
6. Run the Workflow:
o Execute the workflow to trigger the Ctrl + S key press, type the file path (if needed), and press
Enter to save the file.
Output:
7: Create a variable dayOfWeek of type String to store the current day (e.g., "Monday","Friday",
"Saturday").
Use the Switch activity to display greetings based on the dayOfWeek
o Switch Activity:
Expression: dayOfWeek
 If dayOfWeek is "Monday", it will show "Start your week with energy!".
 If dayOfWeek is "Friday", it will show "Happy Friday!".
 If dayOfWeek is "Saturday", it will show "Have a relaxing weekend!".
 If dayOfWeek is "Sunday", it will show "Enjoy the last day of the weekend!".
 For any other day, it will show "Have a great day
Steps
1. Create a Sequence:
o Start by creating a new Sequence activity in UiPath Studio.
2. Create a Variable:
o Create a variable dayOfWeek of type String to store the current day of the week.
o You can initialize dayOfWeek to any value (e.g., "Monday") or use an Assign activity to get
the current day using the DateTime.Now.DayOfWeek.ToString() method.
Example: dayOfWeek = DateTime.Now.DayOfWeek.ToString()
3. Add a Switch Activity:
o Drag and drop a Switch activity into the sequence.
o Set the Expression property of the Switch activity to dayOfWeek.

4. Define Cases in the Switch Activity:


o In the Cases section of the Switch activity, define the following cases:
o Case 1: Monday
 Condition: "Monday"
 Action: Add a Message Box activity with the text: "Start your week with energy!"
o Case 2: Friday
 Condition: "Friday"
 Action: Add a Message Box activity with the text: "Happy Friday!"
o Case 3: Saturday
 Condition: "Saturday"
 Action: Add a Message Box activity with the text: "Have a relaxing weekend!"
o Case 4: Sunday
 Condition: "Sunday"
 Action: Add a Message Box activity with the text: "Enjoy the last day of the weekend!"
o Default Case (For any other day):
 Action: Add a Message Box activity with the text: "Have a great day!"
5. Run the Workflow:
o Execute the workflow to see the greeting message based on the current day of the week.
Output:

8: Using uipathstudio automate the given task


o Open Browser ("https://example.com/products")
o Element Exists ("Product List Header")
o If True:
 Find Children (Parent Element: "Product List")
 For Each Product Item:
 Get Ancestors → Find Parent Div of Product
 Find Children → Get Product Name and Price
 Use Element Anchor to find Price next to the Product Name
o Close Browser
Steps
1. Open Browser:
o Start by creating a new Sequence activity.
o Add an Use Application/Browser activity.
o Set the URL property to " https://www.amazon.in/s?k=rpa ".

2. Check if "Product List Header" Exists:


o Add an Element Exists activity to check if the "Product List Header" is present on the page.
o Set the Element property to the "Product List Header" element selector.
o Store the output of this check in a Boolean variable, such as elementExists.
Example: Element Exists: "Product List Header" → Result: isProductListHeaderExist

3. If Product List Header Exists:


o Use an If activity to check if the elementExists variable is True.
4. Extract Name and Price of the Product:
o Inside the If activity, in the Then section, add a Extract Table Data activity and indicate
the name and the price elements on screen.
o Store the results in DataTable variable.

5. For Each Item:


o Use a For Each Row in Data Table activity to loop through each item in the DataTable variable.
o Add a Write Line activity inside the body and set the Text as:
"Name: " + row(0).ToString() + "| Price: " + row(1).ToString()
6. Close Browser:
o After the loop completes, add a Close Browser activity to close the browser.
Output:

9: Use the basic recording and do the automation of opening notepad. Type Into activity to type the text
("Hello, UiPath!") in the Notepad window. Click activity to interact with the File menu, select Save As,
and save the file to the disk.
Steps
1. Start a New Recording:
o Open UiPath Studio and create a new project.
o Use Basic Recording to capture the steps for automating Notepad.
2. Open Notepad:
o Click on Record and select the Open Application option to launch Notepad.
o In the Notepad window, you can click on the "Start" menu and type Notepad to open it. UiPath
will capture this action.

3. Type Text into Notepad:


o After the Notepad window is opened, use the Type Into activity to type "Hello, UiPath!".
o The Type Into activity will simulate typing the text into the Notepad window.
Example:
o Set Text property of Type Into activity to "Hello, UiPath!".
o Set Selector property to the Notepad window, ensuring it targets the text area where the text
will be typed.
4. Click on File Menu:
o Add a Click activity to interact with the File menu.
o Capture the File menu element by clicking on it during the recording.

5. Select "Save As" Option:


o After clicking on the File menu, use the Click activity again to select the Save As option
from the menu.
6. Type the File Name:
o Use Type Into to enter a file name for saving the Notepad file (e.g., Example.txt).
o You can capture this input action during the recording as well.

7. Click Save:
o Add another Click activity to click on the Save button in the Save As dialog box.

8. Close Notepad:
o After saving, use a Close Application activity to close Notepad.
Output:

10: Use web recording perform the following Open Google: Type https://www.google.com in the address
bar and press Enter. Type UiPath in the Google search bar and press EnterClick on the first result: After
the search results load, click on the first search result linkAfter performing the actions, click on the Stop
Recording button.
Steps
1. Start a New Web Recording:
o Open UiPath Studio and create a new project.
o In the Design tab, select Recording and choose Web Recording.
2. Open Google:
o When the Web Recording toolbar opens, click on Start Recording.
o In the Address Bar of the browser, type https://www.google.com and press Enter.
o UiPath will automatically capture this action and generate the appropriate activity for opening
Google.
3. Type "UiPath" in the Google Search Bar:
o Once Google loads, click on the Search Box (Google's search bar).
o Type UiPath in the search bar and press Enter.
o The Type Into activity will be used to type the search term, and the Send Hotkey activity
will simulate pressing Enter.
4. Click on the First Search Result:
o After the search results load, hover over the first search result link.
o Click on the first result link to open it. UiPath will capture this as a Click activity.

5. Stop Recording:
o Once the action is complete, click on the Stop Recording button in the Web Recording toolbar.
Output:

--- END ---

You might also like