By: Arif Khan
Hello guyz. In last sessions, we finalized the installation of Python Robot Framework pre-requisites and build the basic structure of Python Robot Framework project using Pycharm virtual environment. As you see in below image I have organize my tests into tests folder based on the product, as I want to perform test on Google that is why I placed the Google folder in tests folder. You can further organize your tests into more sub-sections as I did. Like I have divide my tests into Test Suits that is why I have made two more folder within Google folder like FunctionalTestSuit and RegrationTestSuit this will provide you more clarity on the test cases, as you can see in below screen shot.
Basic Robot Framework Project Structure
Defining the key sections
Now lets get ahead and building Robot Framework project and start first script step by step.
- Right click at the folder named FunctionalTestSuit which laying under Google folder and select new then file from context menu.
- Write the file name as GoogleSearch.robot and hit enter. (keep this in mind that robot is the extension of Python Robot Framework file) as soon as you create a file with robot extension Framework will detect that it is a robot file and robot icon will appear at the beginning of your newly created file, and Pycharm will give you the blank code editor at right side.
- There are four key sections of .robot file. At this time just remember them, later on we will discuss about these key sections in detail.
- *** Settings ***
- *** Variables ***
- *** Test Cases ***
- *** KeyWords ***
About *** Settings ***
In *** Settings *** section you can define the documentation, import libraries, import other resources etc. In this session we will just import library in this section.
About *** Variables ***
In *** Variables *** section you can define variables to utilize in test case. It will be covered in later tutorials.
About *** Test Cases ***
In *** Test Cases *** as the name of this section is pretty self-explanatory, you can write the test case documentation and the script of your test case in here.
About *** Keywords ***
The *** Keywords *** section is optional, you can define your keywords here in this section, most of the time you will be moving it to the separate file all together, if you are defining your own keywords, then you could import that file in *** Settings *** section.
That all about the creation of your first project of Python Robot Framework its structure and four important key sections of .robot file.
In next session I will tell you about writing a test case script. Till then take care.
Feel free to ask or comment in comment section below.