Webinar

July 20, 2021 12:00 PM EDT
Automation for healthcare providersJuly 20, 2021 12:00 PM EDT
$25,000 in giveaways for attendees - get your first bot implementation for free

Certificate level II: Build a robot

Robocorp level II certification course

Robocorp makes RPA accessible to everyone through license-free open source technologies delivered from a cloud platform. Join us and learn to build and orchestrate software robots with Robocorp's developer tools and RPA Framework's open-source libraries.

By completing this certification course, you demonstrate you understand the concepts of Robocorp and can build a robot on your own. You are provided with a task to automate and hints for building the robot.

Ask for guidance from your teammates, Robocorp Slack (#rpa-developer-training channel), or the forum.

The purpose is to strengthen your robot-building skills, so focus on learning the ropes! Do this for you, not for us! We review the certification course robots, so make sure you do not copy-paste a ready-built solution!

Expected results in a nutshell

You need to complete:

  1. A robot that completes the certification course assignment.
  2. A short exam questionnaire.

See the rules for the robot for the detailed robot requirements.

Prerequisites โ˜๏ธ

It is highly recommended to update the conda.yaml file to use rpaframework version 10.3.0 or whatever version is the latest when you start.

Download Robocorp tools

I love command-line! Any tools available for me?

Try RCC (a command-line tool that allows you to create, manage, and distribute Python-based self-contained automation packages - or robots ๐Ÿค– as we call them.)!

Robocorp automation stack

Robocorp automation stack

Short intro of the process you are going to automate ๐ŸŽฅ

RobotSpareBin Industries Inc. - Robot order form

Order complete

The process intro is available as a video.

Rules for the robot ๐Ÿ“š

My dear, without rules there's only chaos. - Star Wars: The Clone Wars: Senate Murders (2010)

  • The robot should use the orders file (.csv ) and complete all the orders in the file.
Order number,Head,Body,Legs,Address
1,1,2,3,Address 123
2,4,1,5,Address 456
3,6,2,3,Address 789
4,2,3,2,Address 1
5,3,5,1,Address 2
6,1,6,6,Address 3
7,5,1,5,Address 4
8,2,3,3,Address 5
9,3,2,2,Address 6
10,4,4,2,Address 7
11,6,6,1,Address 8
12,1,3,3,Address 9
13,1,5,4,Address A
14,3,1,5,Address B
15,3,2,6,Address C
16,6,3,6,Address D
17,5,4,1,Address E
18,2,5,1,Address F
19,4,6,2,Address G
20,1,1,5,Address H

orders.csv

  • Only the robot is allowed to get the orders file. You may not save the file manually on your computer.
  • The robot should save each order HTML receipt as a PDF file.
  • The robot should save a screenshot of each of the ordered robots.
  • The robot should embed the screenshot of the robot to the PDF receipt.

Receipt PDF

  • The robot should create a ZIP archive of the PDF receipts (one zip archive that contains all the PDF files). Store the archive in the output directory.
  • The robot should complete all the orders even when there are technical failures with the robot order website.
  • The robot should read some data from a local vault. In this case, do not store sensitive data such as credentials in the vault. The purpose is to verify that you know how to use the vault.
  • The robot should use an assistant to ask some input from the human user, and then use that input some way.
  • The robot should be available in public GitHub repository.
  • Store the local vault file in the robot project repository so that it does not require manual setup.
  • It should be possible to get the robot from the public GitHub repository and run it without manual setup.

1. Complete the order process manually

Before you start with automation, complete the order process manually to see how it works. It is easier to automate a process you are familiar with:

https://robotsparebinindustries.com/#/robot-order

2. Create a new template robot with Visual Studio Code, RCC, or Robocorp Lab.

You do not have to start from scratch. The Visual Studio Code extension, RCC, and Robocorp Lab can create a simple template robot for you.

Option A - Visual Studio Code

Robocorp Visual Studio commands

  • Press Shift-Command-P (macOS) or Ctrl+Shift+P (Windows / Linux) to open the Command Palette.
  • Select Robocorp: Create Robot.
  • Select the standard template.
  • Enter a name for the robot.

Option B - RCC

  • Use the interactive robot creation command:
rcc create
  • Enter a name for the robot (or accept the default my-first-robot by pressing Enter).
  • Select the standard template by pressing 3.

Option C - Robocorp Lab

Robocorp Lab - Create new robot

  • Click Create new robot.
  • Enter a name for the robot.

3. Open the tasks.robot file inside the created robot directory

Template robot

4. Run the template robot

Visual Studio Code

  • Open the Command Palette.
  • Select Robocorp: Run Robot (or navigate to the task you want to run by clicking the Robocorp icon in the Activity Bar on the left).

RCC

rcc run

Robocorp Lab

  • Click the Run Robot button.

5. View the robot log

When run, the robot should log a greeting.

Visual Studio Code

Visual Studio Code - Log path

  • Command-Click (macOS) or Ctrl+Click (Windows / Linux) the path to the log file in the debug console. This opens the log as a HTML file. You can install the open in browser extension and press Option-B (macOS) or Alt+B (Windows / Linux) to open the HTML file in your default browser.

You can leave the log tab open in your browser and return to it whenever you want to check the log. Just remember to refresh the page to see the changes!

Robocorp Lab

Robocorp Lab - Log button

  • View the log by pressing the Log button.

6. Update the robot description

A good description goes a long way in communicating the purpose and the task of your robot.

*** Settings ***
Documentation     Orders robots from RobotSpareBin Industries Inc.
...               Saves the order HTML receipt as a PDF file.
...               Saves the screenshot of the ordered robot.
...               Embeds the screenshot of the robot to the PDF receipt.
...               Creates ZIP archive of the receipts and the images.

7. Update the name of the task

A well-named task summarizes the thing that the robot is supposed to complete.

*** Tasks ***
Order robots from RobotSpareBin Industries Inc

See Naming best practices for robots and coding in general.

Build the rest of the robot! ๐Ÿ˜€

If you have prior experience with Robot Framework and automation, you can proceed however you like. Try to build a robot that does the manual process automatically, completing all the orders in the .csv file (even when there are occasional errors with the website)!

Here is some inspiration for what the finished *** Tasks *** section might look like. Take it only as inspiration. You do not need to follow it blindly, but it can be useful for determining what steps need to be implemented so that the robot can complete the process. You could reach the end goal in many ways!

You could implement all the things inside the Tasks section without defining any custom keywords, but the robot might be easier to maintain if you use well-named keywords that do only one thing but do it well (just like in programming in general; short functions that do only one thing but do it well!).

The task calls custom keywords, such as Open the robot order website, Get orders, and Close the annoying modal. None of these keywords exist in Robot Framework or third-party libraries. They are just plain English keywords to make the intention of the robot more clear.

Each of these keywords needs to be implemented. Otherwise, they do nothing. If you want to, you can try and implement the keywords one by one until the full process is automated. Good luck!

*** Tasks ***
Order robots from RobotSpareBin Industries Inc
    Open the robot order website
    ${orders}=    Get orders
    FOR    ${row}    IN    @{orders}
        Close the annoying modal
        Fill the form    ${row}
        Preview the robot
        Submit the order
        ${pdf}=    Store the receipt as a PDF file    ${row}[Order number]
        ${screenshot}=    Take a screenshot of the robot    ${row}[Order number]
        Embed the robot screenshot to the receipt PDF file    ${screenshot}    ${pdf}
        Go to order another robot
    END
    Create a ZIP file of the receipts

Since none of the keywords are implemented yet, running the robot will not succeed. One way to proceed could be to comment out all the other keyword calls but the one that you are currently implementing, like here, where we leave Open the robot order website uncommented, and comment out everything else:

*** Tasks ***
Order robots from RobotSpareBin Industries Inc
    Open the robot order website
    # ${orders}=    Get orders
    # FOR    ${row}    IN    @{orders}
    #     Close the annoying modal
    #     Fill the form    ${row}
    #     Preview the robot
    #     Submit the order
    #     ${pdf}=    Store the receipt as a PDF file    ${row}[Order number]
    #     ${screenshot}=    Take a screenshot of the robot    ${row}[Order number]
    #     Embed the robot screenshot to the receipt PDF file    ${screenshot}    ${pdf}
    #     Go to order another robot
    # END
    # Create a ZIP file of the receipts

All the lines beginning with the comment sign (#) are ignored when running your robot. As you progress, you can start removing the comment signs!

8. Open the robot order website

To get things started, you need to implement a keyword for opening the robot order website. Here's a draft for the keyword. You need to add the implementation (calling keywords to accomplish things):

*** Keywords ***
Open the robot order website
    Replace this line with a suitable keyword

Visual Studio Code: You can place the *** Keywords *** section either before or after the *** Tasks *** section. The order does not matter. You only need one *** Keywords *** section heading at the top; no need to add one for each of the keywords.

Robocorp Lab: You need to place the *** Keywords *** section before the *** Tasks ***, since the Notebook is parsed from top to bottom. If you want to split each keyword in its own cell, add the *** Keywords *** section heading on top of each of the keywords. Otherwise, they will all be in the same cell. Up to you!

Hints

  • You need a library that knows how to work with a web browser. Robocorp provides two browser libraries.
  • One of the browser libraries provides a keyword that handles installing the browser drivers for you (read the keyword descriptions to find one that does this). The other browser library installs both the browsers and the browser drivers!
  • After you find a suitable browser library, you need to import the library to your robot script.
  • After importing the library, call the keyword for opening the browser. See the keyword documentation for the required keyword arguments. You might need to provide the URL of the robot order website!

When you get the robot order website to open in a web browser, you can proceed to the next step!

9. Download the orders file, read it as a table, and return the result

${orders}=    Get orders

Hints

  • The orders CSV file is here: https://robotsparebinindustries.com/orders.csv
  • You need an RPA Framework library for downloading things.
  • You want to overwrite the downloaded file if it exists to be able to run your robot over and over again. There is a keyword argument for telling that overwriting is ok!
  • There is an RPA Framework library for reading CSV files into tables that can then be looped in a robot script.
  • You need your custom Get orders keyword to return the result. See the Robot Framework keywords article. There's a section about returning things from a keyword.
  • Learn about assigning variables to assign the returned orders to a variable.

You can check if your code works from the log after you run your robot.

10. Loop the orders

You need to complete the ordering process for each of the orders.

Hints

  • You need to use a for loop.
  • For now, you can just log each order row inside the loop.
  • The task draft already contains valid for loop syntax, so you can steal that if you like!

11. Give up all your constitutional rights!

Time to get rid of that annoying modal that pops up when you open the robot order website. Let's implement the Close the annoying modal keyword.

Hints

  • You have already imported the library you need.
  • Keywords that click on things might prove useful here.
  • The "click on stuff" keywords need a locator so that they know what to click on. Locators are the bread and butter of automating web applications. It is good to spend some time reading about those.
  • You can use the browser inspector tools to find the elements to click on.
  • You can target HTML elements either with CSS type, class, ID, or attribute selectors or XPath expressions, or a combination of CSS, XPath, and text selectors.

12. Fill the form

Time to tackle the Fill the form keyword. This example keyword takes an argument.

Hints

  • Check the docs on using keyword arguments.
  • Use the order row that you got from the loop you built as the argument for this form filler keyword.
  • If the name of the variable you got from the loop is, for example, ${row}, you can access the value of the Head column like this: ${row}[Head].
  • You need keywords for selecting things and inputting text. You have a library you need already imported!
  • The input element for the leg number is slightly annoying. It does have an id attribute, but the value seems to change all the time! ๐Ÿคฌ Can you think of a way of targeting that element? There are no "correct" answers here, just many options!

13. Preview the robot

To robotically get the image of the robot, the robot needs to preview the robot (Yo Dawg!).

Hints

  • Click on stuff. Business as usual!

14. Submit the order

This one is a bit trickier case. Sometimes the submit fails. We really want the robot to complete the orders even when there are occasional errors on submit. How do we do that? ๐Ÿค”

Hints

15. Store the order receipt as a PDF file

${pdf}=    Store the receipt as a PDF file    ${row}[Order number]

Hints

  • You need to import an RPA Framework library that handles PDF files.
  • The keyword needs to take an argument (the order number - to be used in the file name to ensure a unique name) and return a result (the file system path to the PDF file).
  • The Beginners' course contains a chapter about this exact topic.
  • You want to store the PDF files inside the output directory (you can use subdirectories such as receipts inside the output dir if you like), since that location is supported by Robocorp Cloud when it stores the process output artifacts. If you place stuff elsewhere, it will not end up in Robocorp Cloud process output artifacts.
  • There is a runtime variable for the output directory path. Can you find it?
  • The directory path separator is operating-system-specific. There is a built-in variable for that separator.

16. Take a screenshot of the robot image

${screenshot}=    Take a screenshot of the robot    ${row}[Order number]

Hints

  • This is similar to the last keyword you implemented (takes an argument, returns a result).
  • You have a library you need already imported.

17. Embed the robot screenshot to the receipt PDF file

Embed the robot screenshot to the receipt PDF file    ${screenshot}    ${pdf}

Hints

  • You have the library you need already imported.
  • Before you can write to a PDF document, you need to open it for writing.
  • After writing to a PDF document, it is good to close it.

18. Go to order another robot

If you got this far, this might be pretty straightforward! Congratulations!

19. Create a ZIP file of the receipts

When you want to run your robots in Robocorp Cloud and get access to the robot output artifacts (such as the files the robot generates), you want to store the files in the output directory. Since Robocorp Cloud does not support subdirectories for the output artifacts, you need to ZIP the receipt PDFs.

The output directory can be changed by modifying the robot.yaml configuration file!

Hints

  • You need an RPA Framework library that can create ZIP archives.
  • The PDF invites creator has an example of creating a ZIP archive.

20: Configure and run the robot as an assistant that asks for user input

You have made it this far already - amazing! Good job!

One of the requirements was to run the robot as an assistant that asks the user for some input. Modify the robot so that it will ask for some input and use that input in some way.

Hints

  • Maybe ask the user to provide the URL of the orders CSV file?

Connect to Robocorp Cloud

Visual Studio Code

Link to Robocorp Cloud from Visual Studio Code.

Robocorp Lab

Link Robocorp Lab with Robocorp Cloud.

Upload the robot to Robocorp Cloud

Upload the robot code to Robocorp Cloud.

Run the robot as an assistant

Using Robot Assistants in Robocorp Cloud.

21: Read some data from a vault

Another requirement was to read some data from a vault. Modify the robot so that it reads some data from a local vault file. Store the vault file in the robot project so that it does not require manual setup.

The best practice is to store the vault file outside the robot project, but in this case, we make an exception since we do not want you to store sensitive data in the vault. We just want to see that you know how to access the vault and read some data!

Hints

  • Maybe store the URL of the robot order website in the vault?

22: Publish your robot in a public GitHub repository

Create a public GitHub repository for your robot and push it there.

23: Verify that it is possible to run your robot without manual setup

Make sure your robot works out-of-the-box just by getting it from the GitHub repository. For example, the vault should be configured so that the robot finds it without manual setup.

24: Take the certification exam

Robot built? Ready to proceed to the next step?

To pass the Robocorp Level 2 Developer Training, we will ask you to share the URL of your robot repository in the final exam form. We will review the robot and check that it's working. In case you can't get your robot working, please ask for advice on our forum or Robocorp Slack (#rpa-developer-training).

The final exam consists of five questions. You need to answer correctly to four out of five of them. You will see if you passed the exam at the end of this exam. Note that reviewing your robot will take us some time, so you won't get your certificate immediately. You can take the exam as many times as you need and use Robocorp docs to find answers to the exam questions.

Good luck with the exam!

Start the exam


Bonus challenge (optional, but good to know!)

The default behavior for browser automation is to save a screenshot whenever a keyword fails. Unnecessary screenshots make the robot log files unnecessarily large. Unnecessary screenshots are those that are taken when retrying a step that you know might fail. Since you know that these steps might fail from time to time, you are not interested in the screenshots for those failures. Try to improve the robot so that it does not take unnecessary screenshots.

Hints

Troubleshooting

RPA Framework keywords are not recognized by the IDE!

  • Try changing the rpaframework version in conda.yaml file to 10.3.0. Close and reopen the tasks.robot file.

Can I stop the execution mid-run and inspect what is happening inside the robot?

Yes! You can debug your script in VS Code:

  • Add a breakpoint on the line(s) you want.
  • Click on the Robocorp icon in the Activity Bar on the left.
  • Run the robot using the debug button.

Debugging the robot in Visual Studio Code

June 14, 2021