Getting to the intranet
Ok, let's start using our robot to do something useful!
Defining our task
Our robot will not be spending its precious time greeting the world; it has a job to do. Let's start by being ambitious and describe the full job that it will need to do in one phrase. That will become our task description.
We settle on: Insert the sales data for the week and export it as a PDF
In Robocorp Lab, modify the *** Tasks ***
cell like this:
*** Tasks ***
Insert the sales data for the week and export it as a PDF
The first step: opening the intranet
Just like Maria does when she starts working with the sales data, the robot will need to open a browser and navigate to the intranet website.
Great! Let's add it in our task as the first step:
*** Tasks ***
Insert the sales data for the week and export it as a PDF
Open The Intranet Website
Open The Intranet Website
is clear enough for us, but the robot does not yet know what that means. How do we explain that to it? We add a new keyword.
Note that the
Open The Intranet Website
keyword is indented with four spaces (having four spaces before the keyword). We'll explain this in more detail shortly!
Adding a new keyword
Add a new cell before the *** Tasks ***
one by clicking on the +
button in the toolbar, and add this code to it:
*** Keywords ***
Open The Intranet Website
Note: the order is important here.
*** Keywords ***
cells need to be positioned before the cells that refer to them, in our case, the*** Tasks ***
cell.
Great! Now Open The Intranet Website
has become the name of a new keyword. It does not do anything yet though... 🤔 How can we teach our robot to open a browser and work with it?
Adding our first library
The answer is by adding a library. Libraries teach our robots new skills by making new keywords available to them. In our case, we want to work with the browser, so we will add the RPA.Browser.Selenium
library. Libraries are added in the Settings section of robot scripts.
Edit the *** Settings ***
cell so that it reads like this:
*** Settings ***
Documentation Starter robot for the Beginners' course.
Library RPA.Browser.Selenium
RPA.Browser.Selenium
is part of the RPA Framework set of libraries, created and maintained by Robocorp.
Using keywords from a library
To open a browser and navigate to the intranet, we can now use the Open Available Browser
keyword provided by the RPA.Browser.Selenium
library, and give it the address of the intranet as an argument.
Edit the cell containing our own Open The Intranet Website
keyword, so it reads like this:
*** Keywords ***
Open The Intranet Website
Open Available Browser https://robotsparebinindustries.com/
Note: You need to have at least two spaces before the keyword. This is called indentation. The default is to use four spaces. You can indent by pressing the
TAB
key on your keyboard. The spaces are shown here as underscores:
____Open Available Browser
You need to have at least two spaces between the keyword and its arguments. If you only have one space, Robot Framework will consider the argument as part of the keyword name. The spaces are shown here as underscores:
Open Available Browser____https://robotsparebinindustries.com/
Fantastic libraries and where to find them
We have ambitious plans for our robot, and along the way we will add more libraries to make it smarter and allow it to do more things. But how do we know which libraries are available and how they work?
The best place to start is the Libraries page on this very site, where we have put together a list of useful libraries for Robotic Process Automation. Take the RPA.Browser.Selenium
library that we just added for example: it has its own documentation page where you can see examples on how to use it, and the list of all the keywords it provides.
You are not limited to the libraries listed in our site, you can find other libraries around the web, and when you will be more familiar with coding, you can also make your own libraries, it's surprisingly easy!
Ok, now back to our robot!
The robot so far
Now our robot looks like this:
*** Settings ***
Documentation Robot to enter weekly sales data into the RobotSpareBin Industries Intranet.
Library RPA.Browser.Selenium
*** Keywords ***
Open The Intranet Website
Open Available Browser https://robotsparebinindustries.com/
*** Tasks ***
Insert the sales data for the week and export it as a PDF
Open The Intranet Website
Let's run our robot (by clicking on the >>
button in the toolbar at the top), and enjoy the robot starting to work for us:
What we learned
- You should define the task of your robot in one phrase.
- You can define your own keywords and call them in your task.
- Keywords cells need to appear before other cells that refer to them.
- You can get new keywords for your robot by adding libraries.
- Libraries add new capabilities to your robot.
- Libraries are added in the
*** Settings ***
section of your.robot
file. - Testing your robots often, even after each edit, gives you continuous feedback on how your robot functions.
- You can open a browser with the
Open Available Browser
keyword, by giving it the URL you want to open as an argument. - Indentation is important.
- You have to separate arguments and keywords with at least two spaces.
Learn more about the libraries mentioned on this page: