In this tutorial, we're going to create an empty Robot Framework script that will be used for test automation later on.
Robot Framework scripts are plain text files with the extension .robot.
Each robot framework file contains a suite that can contain Tests or Tasks.
Whare are the sections in Robot Framework?
Each file needs to have some predefined sections, examples of Robot Framework sections are given below
- Test Cases
How to define a section in a .robot file?
The sections in an RF script are defined using a specific convention.
The Robot Framework Language Server makes our life easier by helping us do the right things in the correct format.
To see a practical example, Let’s open the Visual Studio Code.
Let’s click Open Folder and select a folder where we’ll store our test automation or RPA Robot Framework scripts which we will create together in this course.
After opening a folder, let’s create a new file to store our Robot framework automation script.
I’ll call it Section1.robot
What is the structure of a section name in Robot Framework?
Now I’ll click in the text editor and type a triple asterisk *** followed by the word settings.
Intellisense will help us do this easily.
*** Settings ***
A section in a robot file is defined by starting a new line with three asterisks, whitespace, the section name, another whitespace, and three asterisks at the end of the line.
I’ll press enter and repeat the same process for some more sections, like Keywords and Test Cases
We can also have a Variables section but I’ll come to it in a later post.
Now save the file by pressing Ctrl + S. I'll call it first-script.robot.
(the file extension of robot script files is .robot)
This is an empty script. But still, we can use it to find out if we've done everything correctly so far or not.
In order to run this empty script, we will click the terminal menu item and select “New Terminal”
Over here, let’s type robot space Section1 press tab and press enter.
The Robot Framework will tell you that the test suite defined in this file doesn’t contain any tests or tasks.
Don’t worry, we’ll fill later.
For now, this means that we have set up Robot Framework correctly and already created an empty shell suite file for our use.