Logging into the intranet
Now that it has opened the browser, our robot needs to log into the intranet, using Maria's credentials.

Let's add the next logical step to our task (again, using human-readable language!). We'll call it Log in
. The *** Tasks ***
section should look like this after adding the step:
Add a new keyword in the *** Keywords ***
section after the Open the intranet website
keyword:
Note that you don't need to add another
*** Keywords ***
heading for each keyword. Your robot will work with or without multiple*** Keywords ***
headings.
Ok! Now we have to tell our robot to find the username and the password fields on the page and fill them.
Finding a form field
You, a human being (just assuming!), can see and find things such as forms and fields on a web page. Your robot, however, lacks both vision and the ability to think. It needs precise instructions to find anything.
A web page is written in HTML (Hypertext Markup Language). It defines the meaning and structure of web content. The RobotSpareBin intranet is also built using HTML.
To find forms, fields, and other elements from an HTML web page, your robot needs to know their selectors. Think of a selector as the street address for an element, such as the username field on the RobotSpareBin intranet login page. These selectors along with their name and other instructions are stored in locators, in a file called locators.json
, from which they can be referenced to in the code or used directly as in-line selectors. Don't worry, this will start to make more sense when we start using the locators.
If you want, you can go deeper and learn more about how to find interface elements in web applications and the concept of locators in this dedicated article.
You don't have to inspect the HTML elements during this course unless you want to. All the HTML snippets are provided right here for your convenience. Still, learning how to find and interact with elements is the bread and butter of web automation, so make some time to learn it well eventually!
Inspecting elements in Chrome looks something like this (all the major browsers provide similar tools):
This is what the username field HTML markup looks like in the intranet login form:
<input type="text" id="username" name="username" required="" class="form-control"/>
It is an input
element. It has several attributes
, such as type
, id
and name
. We can use these to locate (find) the elements.
Inputting text to form fields
We need to tell the robot to fill in the login form. The RPA.Browser.Selenium
library provides a Input Text
keyword that can fill in text fields. The keyword takes two arguments: The locator
argument tells where to input. The text
argument tells what to input.
In our case, we can call the keyword like this to input maria
in the field that has an attribute name
with the value of username
:
Input Text
is the keyword, username
is the first argument (the locator) and maria
is the second argument (the text to input).
Note that you need to have at least two spaces between the keyword and each of the arguments.
Let's try this keyword call in the interactive console. In the interactive console prompt, type input
and select Input Text
from the list, and hit Enter
. Note that this time the auto-completion also adds the names of the required arguments for you as placeholders (locator
, text
). Useful! Now you know that you have to provide at least those arguments to call that keyword.
Replace the locator
placeholder with username
and the text
placeholder with maria
and hit Enter
. The robot should input maria
in the username field on the login form.
Filling and submitting the form
Modify the Log in
keyword so that it looks like this (you can copy the keyword call from the interactive console or type it in - remember the auto-completion shortcut!):
Inputting passwords
Great! Now we can do the same thing for the password: the only difference is that we should use the more specific Input Password
keyword. This keyword accepts the same arguments, with the difference that it will not output the value of our secret password in the log.
Note: You should never write or commit your credentials in your robot code in a real project. Here we break that rule to keep things simple! Learn more about using credentials in a safe way.
You can copy the password from the login form description (top-notch security right there!). Our Log in
keyword looks like this now:
Worth repeating: Human-readable'ish!
Submitting forms
As the last step, the robot needs to submit the form, which we can do by calling the Submit Form
keyword:
An excellent opportunity for building auto-completion muscle memory: Type
su
and pressControl-Space
(macOS) orCtrl+Space
(Windows). Auto-completion avoids typos, saves your fingers, keeps your keyboard switches in great condition, makes you coffee, and walks your pet! Or at least some of those things!
Here's how the complete robot code looks like now:
Run the robot one more time, and you should see it opening the browser, navigating to the intranet, and happily logging in, just like Maria does! And the robot is quite human-readable, too!
Optimizing your course completion time (time is money!)
You now have a general understanding of how robots are built (define tasks and keywords, import libraries, run and iterate.). Congratulations!
You have real-world experience with typing out robot code both in the editor and in the interactive console. You know about the great auto-completion features.
You can now start taking shortcuts to save your precious time.
- Feel free to copy & paste the code blocks unmercifully. You can type things out if you want to.
- Do read the explanations.
- You will have plenty of chances to build robots from scratch and dive into details later.
- This course will not go away. You can always revisit it when you feel like it!
What we learned
- You can use the
Input Text
keyword from theRPA.Browser.Selenium
library to fill text input fields. - You can tell your robots which elements in a webpage to act on by writing locators (or selectors).
- You should use the
Input Password
keyword to fill password fields. - You should not write or commit credentials directly into your project. We do it here to keep things simple, but you should never do this in the real world.
- The code auto-completion can fill in the required keyword argument placeholders for you.
- Learning how to find and interact with elements is the bread and butter of web automation.
- Did we mention that auto-completion is great? Well, it is!