Getting to the intranet

Ok, let's teach our robot something useful!

Create a user keyword

User Keywords (Custom Keywords) are a practical way to group related functionality and make code that you want to call from multiple places. They are similar to functions, methods, or procedures in other programming languages.

Click on the plus button (+) next to "User keywords" in the left panel to create an user keyword, and call it "Open the intranet website". Click the newly created user keyword in the left sidebar to open it.

If you have already code in your editor that you want to move to a user keyword, there is a trick: You can also create User Keywords quickly from existing code lines by selecting all the keywords you want with shift key pressed and clicking "Create User Keyword" in the right side panel.

Clicking with the shift key pressed selects all adjacent keywords between the first and the last one. You can also use the ctrl key (on a Mac, command key) to select multiple non-adjacent keywords. These same selections can be used to reorder and for copying/pasting multiple keywords.

A third way to create user keywords is to switch to the code view and creating the keywords there.

User keywords can also take arguments as input. Those can be defined from the right panel when the user keyword is open. This can be very powerful when combined with loops and variables to do some action for a list of results, for example.

Opening the intranet

Our robot will not be spending its precious time writing "Done." in the log; it has a job to do. 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.

First we need to open a web browser and navigate to the correct web page.

In the left sidebar under keywords, search for "browser" and drag the "Open Available Browser" keyword to the middle area. Click on the just added keyword and in the right sidebar, add as the url address "".

Open Available Browser

Next, open your task Insert The Sales Data … and drag the Open The Intranet Website from the left sidebar into the middle of the window. And remove the line with Log that prints Done.. Great, now our robot should actually do something!

Run the robot again

Let's run our robot and enjoy the robot starting to work for us. To run the robot, you need to either first navigate to the task and click the "Run" button or then select Command-Shift-R (macOS) or Ctrl+Shift+R (Windows) and press Enter to run the first task in the robot.

You should see the robot opening a web browser and navigating to the given URL.

When building robots, it is quite common that you need to move back and forth between the run and editor view when fixing errors. In VS Code extensions you have some advanced tools for this that are not yet available in Automation Studio, such as code debugging and interactive console.

Keeping the browser open after task completion

You may have noticed that the robot opened the web browser, navigated to the given URL, and then immediately closed the browser.

This automatic closing of the browser is the default behavior of the Selenium library. The reason is to keep the robot from leaving unnecessary browser processes running after it's done. This is important in production use!

However, when developing a robot, it is usually useful to have the browser stay open so that you can continue automating the next parts of the process.

Let's adjust the robot to keep the browser window open. To do this, you need to switch over to the code view from the top-right corner of the editor. In code view, change the line that loads Selenium web automation to this:

Library     RPA.Browser.Selenium    auto_close=${FALSE}

Open Available Browser

Note! In Robot Framework code you need to have two spaces between keyword arguments and also before keyword calls in Tasks and User Keywords. So best to copy-paste the line as-is! Luckily the visual editor in Automation Studio makes our life easy by handling the spaces and some other syntax details for us.

Great, now you've made a change in the code view that prevents the browser window from closing!

Automation Studio is a great tool for safely and incrementally learning the basics of programming. Unlike most other RPA editors, Automation Studio is special in that you can edit your robots both visually and in code. Any changes you make in the code view will be automatically reflected in the visual view, and vice-versa.

Your robot will not be able to further "talk to" a browser that is left open this way (using the auto_close argument). Use the browser only for your reference during development.

Let's use this "do not close the browser" trick during this course so that you will remember it exists. Go ahead and update your library import using the above code! Each new robot run will open a new browser so remember to close them from time to time to avoid drowning in Chromes, Firefoxes, or Safaris. 😅

What we learned

  • Automation Studio let's you switch between visual and code views when editing robots.
  • You can define your own keywords and call them in your task.
  • Your own keywords can call other keywords. Keywordception!
  • 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.