Robot Framework Features – Settings, Libraries, Variables, Keywords, Resources, Reports, Logs

HOME

The previous tutorial has explained What is Robot Framework and its advantages. This tutorial will explain the various features available in this framework.

1. Settings

The Setting section is used to import libraries, resource files, and variable files and to define metadata for test suites and test cases. It can be included in test case files and resources.

The most commonly used are:

NameDescription
LibraryUsed for importing libraries.
ResourceUsed for taking resource files into use.
DocumentationUsed for specifying a test suite or resource file documentation.
VariablesUsed for taking variable files into use.
MetadataUsed for setting free test suite metadata.
Test SetupUsed for specifying a default test setup.
Test TeardownUsed for specifying a default test teardown.
Test TemplateUsed for specifying a default template keyword for test cases.

Example of Setting:

*** Settings ***
Documentation    To validate the Login Form
Library     SeleniumLibrary
Test Teardown    Close Browser

2. Test Cases

The settings in the Test Case section are always specific to the test case for which they are defined. Some of these settings override the default values defined in the Settings section.

Example of Test Case:

*** Test Cases ***
Validate Unsuccessful Login
    Open the Browser with URL
    Fill the login form
    Verify error message is correct

3. Keywords

The Keyword section settings are unique to the user keyword for which they are defined. The robot architecture includes built-in keywords as well as keywords from libraries such as the Selenium Library. (open browser, close browser, maximize browser, etc.). We can also make user-defined keywords out of other user-defined keywords or built-in or library keywords. We can also give arguments to those keywords, which turns them into functions that can be reused.

Example of Keywords:

*** Keywords ***
Open the Browser with URL
    Create Webdriver    Chrome  executable_path=/Vibha_Personal/RobotFramework/drivers/chromedriver_linux64
    Go To    https://opensource-demo.orangehrmlive.com/web/index.php/auth/login
    Maximize Browser Window
    Set Selenium Implicit Wait    5

4. Libraries

Many external libraries, such as SeleniumLibrary, Database Library, FTP Library, and HTTP Library, are supported by the Robot architecture. SeleniumLibrary is mostly used to communicate with browsers and aid in web application and UI testing. Robot framework also includes its own libraries for strings, dates, integers, and so on.

Normally, test libraries are imported by selecting the Library option in the Setting section and entering the library name in the following column. The collection name, unlike most other data, is case and space sensitive. If a library is part of a package, use the complete name, including the package name.

Example of Libraries:

Library     SeleniumLibrary
Library     String

5. Variables

Variables which are defined in the *** Variables *** section are available in all test cases and keywords in the same file.
Variables defined in the *** Variables *** section are suite variables.
If a .resource or a .robot file with a *** Variables *** section is imported into a test suite, and the variables there also become suite variables.

Example of Variables:

 ${result}=  Get Text    CSS:.oxd-alert-content-text

6. Resources

Resource files are imported using the Resource setting in the Settings section so that the path to the resource file is given as an argument to the setting.  The robot framework also allows the import of robot files with keywords externally to be used with test cases. Resources are very easy to use and are of great help when we need to use some keywords already written for other test projects.

Example of Resource File:

*** Settings ***
Documentation
Library     SeleniumLibrary

*** Variables ***
${valid_username}     Admin
${valid_password}       admin123
${invalid_username}     1234
${invalid_password}     45678
${url}      https://opensource-demo.orangehrmlive.com/web/index.php/auth/login

*** Keywords ***

Open the Browser with URL
    Create Webdriver    Chrome  executable_path=/Vibha_Personal/RobotFramework/drivers/chromedriver_linux64
    Go To       ${url}
    Maximize Browser Window
    Set Selenium Implicit Wait    5

Close Browser Session
    Close Browser

7. Reports and Logs

The robot framework provides all test suite and test case execution details in the shape of reports and logs. The log file contains all the test case’s execution information. Details such as whether the test case failed or passed, the time required for execution, and the steps needed to run the test case are provided.

Report

Log

That’s it! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s