In this tutorial, we will discuss various commands to execute the tests in Robot Framework using Selenium WebDriver.
Prerequisite:
- Install Python
- Install PIP
- Install Robot Framework
- Install Robot framework Selenium Library
- 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!!