How to set variable values from Runtime command in Robot Framework

HOME

In this tutorial, we will set the variable values from the Run time command argument in Robot Framework using Selenium WebDriver and Python.

Variables can be changed from the command line using the –variable (-v) option or a variable file using the –variablefile (-V) option. Variables set from the command line are universally accessible for all executed test data files, and they override any variables with the same names in the Variable section and variable files imported into the test data.

Individual variables are established using the syntax –variable name:value, where name is the variable’s name without the $ symbol and value is its value. This option can be used multiple times to define multiple variables. This syntax can only be used to establish scalar variables, and they can only receive string values.

Prerequisite:

  1. Install Python
  2. Install PIP
  3. Install Robot Framework
  4. Install Robot framework Selenium Library
  5. Install PyCharm IDE

Please refer to this tutorial to install Robot Framework – How to install and setup Robot Framework for Python.

Implementation Steps:

Step 1.1 – Open PyCharm and create a new project. Go to File and select “New Project” from the main menu.

Step 1.2 – Choose the project location. Click the “Browse” button next to the Location field and specify the directory for your project.

Deselect the Create a main.py welcome script checkbox because you will create a new Python file for this tutorial.

Step 1.3 – A new dialog will appear asking to Open the project using any one of the given options. I have selected New Window as I like to have separate windows for each project.

Below is the image of the new project created in PyCharms.

Step 2 – Create a new directory in the new project

Right-Click on the project, select New->Directory and provide name as PageObject

Below is the image of the new directory.

Right-click on the new directory select New File and provide the name LoginPage.robot as shown below:

Step 3 – Download ChromeBinaries from the below location

The tests are going to use the Chrome browser, so we need to download the ChromeBinaries to open a blank browser in Chrome.

https://chromedriver.chromium.org/

The chromedriver and geckodriver are placed in a folder name drivers in the RobotFramework_Demo project. I have renamed chromedriver to chrome and geckodriver to firefox.

Step 4 – Create a simple Selenium Test

*** Settings ***
Documentation       Tests to login to Login Page
Library     SeleniumLibrary

*** Variables ***
${valid_username}     Admin
${valid_password}       admin123
${invalid_username}     1234
${invalid_password}     45678
${blank_username}
${blank_password}
${url}      https://opensource-demo.orangehrmlive.com/web/index.php/auth/login
${browser_name}      Chrome
${login_error_message}      css:.oxd-alert-content--error
${dashboard_title}       css:.oxd-topbar-header-breadcrumb-module
${missing_username_error_message}    xpath://*[@class='oxd-form']/div[1]/div/span
${missing_password_error_message}   xpath://*[@class='oxd-form']/div[2]/div/span


*** Test Cases ***

Validate Unsuccessful Login using invalid credentials
    [Tags]    SMOKE
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${invalid_password}
    Verify the error message is correct
    Close Browser Session

Validate Unsuccessful Login for blank username
    [Tags]    REGRESSION
    Open the Browser with URL
    Fill the login form     ${blank_username}       ${valid_password}
    Verify the error message is displayed for username
    Close Browser Session

Validate Unsuccessful Login for blank password
    [Tags]    SMOKE     REGRESSION
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${blank_password}
    Verify the error message is displayed for password
    Close Browser Session

Validate successful Login
    [Tags]    UAT
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${valid_password}
    Verify Dashboard page opens
    Close Browser Session

*** Keywords ***

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

Fill the login form
   [Arguments]    ${username}      ${password}
   Input Text    css:input[name=username]   ${username}
   Input Password    css:input[name=password]   ${password}
   Click Button    css:.orangehrm-login-button

Verify the error message is correct
    Element Text Should Be    ${login_error_message}    Invalid credentials

Verify Dashboard page opens
    Element Text Should Be    ${dashboard_title}      Dashboard

Verify the error message is displayed for username
     Element Text Should Be    ${missing_username_error_message}      Required

Verify the error message is displayed for password
      Element Text Should Be    ${missing_password_error_message}      Required

Close Browser Session
    Close Browser

Step 5 – Set Variable values from the Runtime command

In the above example, we are using the Chrome browser to run the tests. I want to run the tests on the Firefox browser, but without making any changes to the existing code. How this can be achieved? We can pass variable

robot --variable browser_name:Firefox .

The output of the above program is

We have the test case passed. The Robot Framework generates log.html, output.xml, and report.html by default.

Let us now see the report and log details.

Report

Right-click on report.html. Select Open In->Browser->Firefox (any browser of your wish).

The Report generated by the framework is shown below:

Log

Robot Framework has multiple log levels that control what is shown in the automatically generated log file. The default Robot Framework log level is INFO.

Right-click on log.html. Select Open In->Browser->Firefox (any browser of your wish).

Variables with Tags

If you want to execute only test scenario tagged with UAT using firefox browser, it can be done using the below command:

robot --variable browser_name:Firefox --include UAT .

The output of the above program is

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

Additional Tutorials

How to Install Python on Windows 11
How to run all the tests from the folder in Robot Framework
How to rerun failed tests in Robot Framework
How to implement tagging in Robot Framework
Page Object Model in Robot Framework with Selenium and Python
How to load data from CSV files in the Robot Framework?

How to run all the tests from the folder in Robot Framework

HOME

In this tutorial, we will discuss various commands to execute the tests in Robot Framework using Selenium WebDriver.

Prerequisite:

  1. Install Python
  2. Install PIP
  3. Install Robot Framework
  4. Install Robot framework Selenium Library
  5. Install PyCharm IDE

Please refer to this tutorial to install Robot Framework – How to install and setup Robot Framework for Python.

Implementation Steps:

Step 1.1 – Open PyCharm and create a new project. Go to File and select “New Project” from the main menu.

Step 1.2 – Choose the project location. Click the “Browse” button next to the Location field and specify the directory for your project.

Deselect the Create a main.py welcome script checkbox because you will create a new Python file for this tutorial.

Click on the “Create” Button.

Step 1.3 – A new dialog will appear asking to Open the project using any one of the given options. I have selected New Window as I like to have separate windows for each project.

Below is the image of the new project created in PyCharms.

How to set variable values from Runtime command?

Step 2 – Create a new directory in the new project

Right-Click on the project, select New->Directory and provide name as PageObject

Below is the image of the new directory.

Right-click on the new directory and select New File and provide the name as LoginPage.robot and ForgetPasswordPage.robot as shown below:

Step 3 – Download ChromeBinaries from the below location

The tests are going to use the Chrome browser, so we need to download the ChromeBinaries to open a blank browser in Chrome.

https://chromedriver.chromium.org/

The chromedriver and geckodriver are placed in a folder name drivers in the RobotFramework_Demo project. I have renamed chromedriver to chrome and geckodriver to firefox.

Step 4 – Create 2 Selenium Tests – LoginPage.robot and ForgetPasswordPage.robot

LoginPage.robot

*** Settings ***
Documentation       Tests to login to Login Page
Library     SeleniumLibrary

*** Variables ***
${valid_username}     Admin
${valid_password}       admin123
${invalid_username}     1234
${invalid_password}     45678
${blank_username}
${blank_password}
${url}      https://opensource-demo.orangehrmlive.com/web/index.php/auth/login
${browser_name}      Chrome
${login_error_message}      css:.oxd-alert-content--error
${dashboard_title}       css:.oxd-topbar-header-breadcrumb-module
${missing_username_error_message}    xpath://*[@class='oxd-form']/div[1]/div/span
${missing_password_error_message}   xpath://*[@class='oxd-form']/div[2]/div/span


*** Test Cases ***

Validate Unsuccessful Login using invalid credentials
    [Tags]    SMOKE
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${invalid_password}
    Verify the error message is correct
    Close Browser Session

Validate Unsuccessful Login for blank username
    [Tags]    REGRESSION
    Open the Browser with URL
    Fill the login form     ${blank_username}       ${valid_password}
    Verify the error message is displayed for username
    Close Browser Session

Validate Unsuccessful Login for blank password
    [Tags]    SMOKE     REGRESSION
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${blank_password}
    Verify the error message is displayed for password
    Close Browser Session

Validate successful Login
    [Tags]    UAT
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${valid_password}
    Verify Dashboard page opens
    Close Browser Session

*** Keywords ***

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

Fill the login form
   [Arguments]    ${username}      ${password}
   Input Text    css:input[name=username]   ${username}
   Input Password    css:input[name=password]   ${password}
   Click Button    css:.orangehrm-login-button

Verify the error message is correct
    Element Text Should Be    ${login_error_message}    Invalid credentials

Verify Dashboard page opens
    Element Text Should Be    ${dashboard_title}      Dashboard

Verify the error message is displayed for username
     Element Text Should Be    ${missing_username_error_message}      Required

Verify the error message is displayed for password
      Element Text Should Be    ${missing_password_error_message}      Required

Close Browser Session
    Close Browser

ForgetPasswordPage.robot

*** Settings ***
Documentation       Tests to validate Forgot Your Password Page functionality
Library     SeleniumLibrary

*** Variables ***
${forgot_password_link}   xpath://div[@class='orangehrm-login-forgot']/p
${forgot_page_title}       css:.orangehrm-forgot-password-title
${username}     css:.oxd-input--active
${reset_btn}     css:.orangehrm-forgot-password-button--reset
${cancel_btn}    css:.orangehrm-forgot-password-button--cancel
${reset_message}      xpath://div[@class='orangehrm-card-container']/h6
${login_page_title}   xpath://*[@class='orangehrm-login-slot']/h5


*** Test Cases ***

Validate Reset Password Functionality

    Open the Browser with URL
    Go to Forgot Your Password Page
    Verify Forgot Your Password Page opens
    Fill the Forgot Password Page
    Verify the message
    Close Browser Session


Validate Cancel Functionality

    Open the Browser with URL
    Go to Forgot Your Password Page
    Verify Forgot Your Password Page opens
    Cancel the Reset Password
    Verify that Login Page is displayed
    Close Browser Session

*** Keywords ***

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

Go to Forgot Your Password Page
    Click Element      ${forgot_password_link}

Verify Forgot Your Password Page opens
    Element Text Should Be    ${forgot_page_title}      Reset Password

Fill the Forgot Password Page
   Input Text        ${username}     abc@gmail.com
   Click Button    ${reset_btn}

Verify the message
    Element Text Should Be    ${reset_message}      Reset Password link sent successfully

Cancel the Reset Password
    Click Button    ${cancel_btn}

Verify that Login Page is displayed
    Element Text Should Be    ${login_page_title}       Login

Close Browser Session
    Close Browser

Step 5 – Execute various Commands

5.1. Execute all tests in a Directory

When we want to execute all the tests present in a directory, we can use the below command:

robot  .

LoginPage contains 4 tests and ForgetPasswordPage contains 2 tests. The output of the above program is

5.2. Execute a test file

When we want to execute only 1 test file present in the directory, we can use the below command:

robot  LoginPage.robot

LoginPage contains 4 tests. The output of the above program executes 4 tests as shown below:

5.3. Execute a test by test name

When we want to execute a test by its name, we can use the below command:

robot -t "Validate successful Login" .

The output of the above program is

5.4. Execute a test by Regular Expression

When we don’t know the complete name of the test case, but a term or functionality, we can use a regular expression to find the test. Here, we have a test with the name “Validate Cancel Functionality” in “ForgetPasswordPage.robot”. So, the regular expression will find this test and will execute.

robot -t "*Cancel*" .

The output of the above program is

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

How to rerun failed tests in Robot Framework

HOME

In this tutorial, we will rerun the failed tests in Robot Framework.

We occasionally experience rendering problems, which cause our Test Cases to fail. And we must run our complete Test Suite once more. This will be a major pain if you are working on a complicated project with many suite files or many Test Cases.

Rerunning only failed test cases after completion and providing a single report can alleviate this major pain in Robot Framework.

Robot Framework provides two attributes “–rerunfailed” and “–merge” merge will rerun the failure and merge the different results for a single report.

Prerequisite:

  1. Install Python
  2. Install PIP
  3. Install Robot Framework
  4. Install Robot framework Selenium Library
  5. Install PyCharm IDE

Please refer to this tutorial to install Robot Framework – How to install and setup Robot Framework for Python.

Implementation Steps:

Step 1.1 – Open PyCharm and create a new project. Go to File and select “New Project” from the main menu.

Step 2 – Choose the project location. Click the “Browse” button next to the Location field and specify the directory for your project.

Deselect the Create a main.py welcome script checkbox because you will create a new Python file for this tutorial.

Click on the “Create” Button.

Step 1.3 – A new dialog will appear asking to Open the project using any one of the given options. I have selected New Window as I like to have separate windows for each project.

Below is the image of the new project created in PyCharms.

Step 2 – Create a new directory in the new project

Right-Click on the project, select New->Directory and provide name as Tests

Below is the image of the new directory.

Right-click on the new directory and select New File and provide the name as RerunFailedTests.robot as shown below:

Step 3 – Download ChromeBinaries from the below location

The tests are going to use the Chrome browser, so we need to download the ChromeBinaries to open a blank browser in Chrome.

https://chromedriver.chromium.org/

The chromedriver is placed in a folder name drivers in the RobotFramework_Demo project.

Step 4 – Create a simple Selenium Test

*** Settings ***
Documentation       Tests to login to Login Page
Library     SeleniumLibrary

*** Variables ***
${valid_username}     Admin
${valid_password}       admin123
${invalid_username}     1234
${invalid_password}     45678
${blank_username}
${blank_password}
${url}      https://opensource-demo.orangehrmlive.com/web/index.php/auth/login
${browser_name}      Chrome
${login_error_message}      css:.oxd-alert-content--error
${dashboard_title}       css:.oxd-topbar-header-breadcrumb-module
${missing_username_error_message}    xpath://*[@class='oxd-form']/div[1]/div/span
${missing_password_error_message}   xpath://*[@class='oxd-form']/div[2]/div/span


*** Test Cases ***

Validate Unsuccessful Login using invalid credentials
    [Tags]    SMOKE
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${invalid_password}
    Verify the error message is correct
    Close Browser Session

Validate Unsuccessful Login for blank username
    [Tags]    REGRESSION
    Open the Browser with URL
    Fill the login form     ${blank_username}       ${valid_password}
    Verify the error message is displayed for username
    Close Browser Session

Validate Unsuccessful Login for blank password
    [Tags]    SMOKE     REGRESSION
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${blank_password}
    Verify the error message is displayed for password
    Close Browser Session

Validate successful Login
    [Tags]    UAT
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${valid_password}
    Verify Dashboard page opens
    Close Browser Session

*** Keywords ***

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

Fill the login form
   [Arguments]    ${username}      ${password}
   Input Text    css:input[name=username]   ${username}
   Input Password    css:input[name=password]   ${password}
   Click Button    css:.orangehrm-login-button

Verify the error message is correct
    Element Text Should Be    ${login_error_message}    Invalid credentials

Verify Dashboard page opens
    Element Text Should Be    ${dashboard_title}      Dashboard

Verify the error message is displayed for username
     Element Text Should Be    ${missing_username_error_message}      Required

Verify the error message is displayed for password
      Element Text Should Be    ${missing_password_error_message}      Required!

Close Browser Session
    Close Browser

Step 5 – Execute the tests

We need the below command to run the Robot Framework script. This is the normal execution of your test suite and save your output in output1.xml

robot --output output1.xml RerunFailedTests.robot

The output of the above program is

Let us check the output1.xml file.

We can see that Test 3 failed here.

Below is the report generated by the Robot Framework

Now, let us rerun the failed tests using the below command. I intentionally failed my test in the last run. In this run, I will fix the test. I will change the expected result from Required! to Required. This checks the failure results in the output1.xml file and reruns the failures once again and saves the new result in the output2.xml file

robot --rerunfailed output1.xml --output output2.xml RerunFailedTests.robot

The output of the above program is

A new output file named output2.xml is generated.

Let us check the output2.xml file.

This command merges the previous XML file and recent XML file after re-run to show in a single report

rebot --output output1.xml --merge output1.xml output2.xml    

The output of the above program is

Check the Report generated by the Robot Framework. We can see all the tests are passed now.

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

How to implement tagging in Robot Framework

HOME

In this tutorial, we will create a project in PyCharms and create TAGS in the tests in Robot Framework using Selenium WebDriver.

The use of tags in Robot Framework is a basic yet effective mechanism for classifying test cases. Tags are free words that can be used for at least the following things:

  1. Tags appear in test reports, logs, and, of course, test data, providing metadata to test instances.
  2. Case-by-case statistics (total, passed, failed are automatically collected based on tags).
  3. You can use tags to include or exclude test cases from being run.
  4. You can use tags to indicate which test cases should be skipped.

Prerequisite:

  1. Install Python
  2. Install PIP
  3. Install Robot Framework
  4. Install Robot framework Selenium Library
  5. Install PyCharm IDE

Please refer to this tutorial to install Robot Framework – How to install and setup Robot Framework for Python.

Implementation Steps:

Step 1.1 – Open PyCharm and create a new project. Go to File and select “New Project” from the main menu.

Step 1.2 – Choose the project location. Click the “Browse” button next to the Location field and specify the directory for your project.

Deselect the Create a main.py welcome script checkbox because you will create a new Python file for this tutorial.

Click on the “Create” Button.

Step 1.3 – A new dialog will appear asking to Open the project using any one of the given options. I have selected New Window as I like to have separate windows for each project.

Below is the image of the new project created in PyCharms.

How to create a tag in the test in Robot Framework?

Step 1 – Create a new directory in the new project

Right-Click on the project, select New->Directory and provide name as Tests

Below is the image of the new directory.

Right-click on the new directory and select New File and provide the name as Test_Demo.robot as shown below:

Step 2 – Download ChromeBinaries from the below location

The tests are going to use the Chrome browser, so we need to download the ChromeBinaries to open a blank browser in Chrome.

https://chromedriver.chromium.org/

The chromedriver is placed in a folder name drivers in the RobotFramework_Demo project.

Step 3 – Create a simple Selenium Test

*** Settings ***
Documentation       Tests to login to Login Page
Library     SeleniumLibrary

*** Variables ***
${valid_username}     Admin
${valid_password}       admin123
${invalid_username}     1234
${invalid_password}     45678
${blank_username}
${blank_password}
${url}      https://opensource-demo.orangehrmlive.com/web/index.php/auth/login
${browser_name}      Chrome
${login_error_message}      css:.oxd-alert-content--error
${dashboard_title}       css:.oxd-topbar-header-breadcrumb-module
${missing_username_error_message}    xpath://*[@class='oxd-form']/div[1]/div/span
${missing_password_error_message}   xpath://*[@class='oxd-form']/div[2]/div/span


*** Test Cases ***

Validate Unsuccessful Login using invalid credentials
    [Tags]    SMOKE
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${invalid_password}
    Verify the error message is correct
    Close Browser Session

Validate Unsuccessful Login for blank username
    [Tags]    REGRESSION
    Open the Browser with URL
    Fill the login form     ${blank_username}       ${valid_password}
    Verify the error message is displayed for username
    Close Browser Session

Validate Unsuccessful Login for blank password
    [Tags]    SMOKE     REGRESSION
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${blank_password}
    Verify the error message is displayed for password
    Close Browser Session

Validate successful Login
    [Tags]    UAT
    Open the Browser with URL
    Fill the login form     ${valid_username}       ${valid_password}
    Verify Dashboard page opens
    Close Browser Session

*** Keywords ***

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

Fill the login form
   [Arguments]    ${username}      ${password}
   Input Text    css:input[name=username]   ${username}
   Input Password    css:input[name=password]   ${password}
   Click Button    css:.orangehrm-login-button

Verify the error message is correct
    Element Text Should Be    ${login_error_message}    Invalid credentials

Verify Dashboard page opens
    Element Text Should Be    ${dashboard_title}      Dashboard

Verify the error message is displayed for username
     Element Text Should Be    ${missing_username_error_message}      Required

Verify the error message is displayed for password
      Element Text Should Be    ${missing_password_error_message}      Required

Close Browser Session
    Close Browser

Scenarios

In the above robot test file, we have a total of 4 tests.

  • Test 1 -> SMOKE
  • Test 2 -> REGRESSION
  • Test 3 -> SMOKE, REGRESSION
  • Test 4 -> UAT

1. To execute the tests tagged with UAT, we have only 1 test, so only 1 test – Test 4 will execute.

robot --include UAT .  

The output of the above program is

2. To execute the tests tagged with SMOKE, we have 2 tests, so 2 tests – Test 1 and Test 3 will execute.

robot --include SMOKE .  

The output of the above program is

3. To execute the tests tagged with SMOKE OR REGRESSION, we have 3 tests, so 3 tests – Test 1, Test 2, and Test 3 will execute.

robot --include SMOKEORREGRESSION .

The output of the above program is

4. To execute the tests tagged with SMOKE AND REGRESSION, we have only 1 test – Test 3 will execute.

robot --include SMOKEANDREGRESSION .

The output of the above program is

5. To execute the tests tagged with not UAT, we have a total of 4 tests and 1 test is tagged with UAT. So now 3 tests should execute – Test 1, Test 2, and Test 3.

robot --exclude UAT LoginPage.robot

The output of the above program is

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

Robot Framework – Working With Browsers Using Selenium Library

HOME

In this tutorial, we will create a project in PyCharms and create a test case in Robot Framework using Selenium WebDriver.

Prerequisite:

  1. Install Python
  2. Install PIP
  3. Install Robot Framework
  4. Install Robot framework Selenium Library
  5. Install PyCharm IDE

Please refer to this tutorial to install Robot Framework – How to install and setup Robot Framework for Python.

Implementation Steps:

Step 1 – Open PyCharm and create a new project. Go to File and select “New Project” from the main menu.

Step 2 – Choose the project location. Click the “Browse” button next to the Location field and specify the directory for your project.

Deselect the Create a main.py welcome script checkbox because you will create a new Python file for this tutorial.

Python best practice is to create a virtualenv for each project. In most cases, PyCharm creates a new virtual environment automatically, and you don’t need to configure anything. But, in this case, we need to create a Base Interpreter that has the robot framework already installed. This is explained in this tutorial – How to install and setup Robot Framework for Python. To preview and modify the venv options. Expand the Python Interpreter: New Virtualenv Environment node and select a tool used to create a new virtual environment. Let’s choose Virtualenv tool, and specify the location of the environment and the base Python interpreter used for the new virtual environment.

Click on the “Create” Button.

Step 3 – A new dialog will appear asking to Open the project using any one of the given options. I have selected New Window as I like to have separate windows for each project.

Below is the image of the new project created in PyCharms.

How to create a Selenium test in Robot Framework?

Step 1 – Create a new directory in the new project

Right-Click on the project, select New->Directory and provide name as Tests

Below is the image of the new directory.

Right-click on the new directory and select New File and provide the name as Test_Demo.robot as shown below:

Step 2 – Download ChromeBinaries from the below location

The tests are going to use the Chrome browser, so we need to download the ChromeBinaries to open a blank browser in Chrome.

https://chromedriver.chromium.org/

Step 3 – Create a simple Selenium Test

*** Settings ***
Documentation    To validate the Login Form
Library     SeleniumLibrary

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


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

Fill the login form
   Input Text    css:input[name=username]   Admin
   Input Password    css:input[name=password]   Admin
   Click Button    css:.orangehrm-login-button


Verify error message is correct
    ${result}=  Get Text    CSS:.oxd-alert-content-text
    Should Be Equal As Strings   ${result}  Invalid credentials

The chromedriver is placed in a folder name drivers in RobotFramework_Demo project.

I will explain the terms Settings, Test Cases, Keywords in the next tutorial.

To run this script, go to the command line and go to directory tests.

We need the below command to run the Robot Framework script.

robot Test_Demo.robot

The output of the above program is

We have the test case passed. The Robot Framework generates log.html, output.xml, and report.html by default.

Let us now see the report and log details.

Report

Right-click on report.html. Select Open In->Browser->Chrome(any browser of your wish).

The Report generated by the framework is shown below:

Log

Robot Framework has multiple log levels that control what is shown in the automatically generated log file. The default Robot Framework log level is INFO.

Right-click on log.html. Select Open In->Browser->Chrome(any browser of your wish).

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

Robot Framework Tutorials

HOME

Robot Framework is a generic open-source automation framework. It can be used for test automation and robotic process automation (RPA). RPA is extensively used for Web Application Automation, API Automation, RPA, and Database Testing.

Robot Framework has an easy syntax, utilizing human-readable keywords. Its capabilities can be extended by libraries implemented with Python, Java, or many other programming languages.

Chapter 1 Robot Framework Features – Settings, Libraries, Variables, Keywords, Resources, Reports, Logs
Chapter 2 What are variables in Robot Framework?
Chapter 3 How to handle text box in Robot Framework
Chapter 4 How to handle radio buttons in Robot Framework
Chapter 5 How to handle checkbox in Robot Framework
Chapter 6 How to handle dropdowns in Robot Framework
Chapter 7 How to handle multiple windows in Robot Framework
Chapter 8 How to handle alerts in Robot Framework
Chapter 9 What is Resource File in Robot Framework 
Chapter 10 How to run all the tests from the folder in Robot Framework
Chapter 11 How to implement tagging in Robot Framework
Chapter 12 How to rerun failed tests in Robot Framework
Chapter 13 How to use Drag and Drop in Robot Framework?
Chapter 14 How to set variable values from Runtime command in Robot Framework
Chapter 15 Page Object Model in Robot Framework with Selenium and Python
Chapter 16 Parallel Testing in Robot Framework
Chapter 17 How to write tests in Robot Framework in BDD Format

Data-Driven Testing

Chapter 1 Data-Driven Testing in Robot Framework 
Chapter 2 How to load data from CSV files in the Robot Framework?

API Testing

Chapter 1 How to perform API Testing in Robot Framework using RequestLibrary
Chapter 2 How to Implement Basic Auth in Robot Framework – NEW
Chapter 3 How to pass authorization token in header in Robot Framework – NEW
Chapter 4 Verifying Status Code and Status Line in Robot Framework – NEW

CI/CD

Chapter 1 Run Robot Framework Tests in GitLab CI/CD
Chapter 2How to run Robot Framework in GitHub Actions

Jenkins

Chapter 1 How to integrate Robot Framework with Jenkins
Chapter 2 How to run parameterized Robot Framework tests in Jenkins