In this tutorial, we will automate the execution of the CheckBox in Robot Framework.
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 – Create a new Project
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 appears 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.

Step 3 – Create a robot Test File
Right-click on the new directory and select New File and provide the name as CheckBox_Demo.robot as shown below:

Step 4 – 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 5 – Automate the selection of options for CheckBox
We are now going to write test cases. The test case details will be as follows −
- Open the browser and copy URL − https://demo.automationtesting.in/Register.html in Chrome.
- Verify that the page contains CheckBox.
- Verify that the page does not contain CheckBox. Provided the locator for Radio button.
- Check “Cricket” and “Hockey” options of CheckBox.
- Uncheck “Hockey” option of CheckBox.
- Verify that “Cricket“ option of CheckBox is checked.
- Verify that “Hockey“ option of CheckBox is not checked.
To work with the Radio Button, we need a locator. A locator is an identifier for the textbox like id, name, class, xpath, css selector, etc.
To know more about locators, refer to these Selenium Tutorials:
Locators in Selenium – Locate by ID, ClassName, Name, TagName, LinkText, PartialLinkText
Dynamic XPath in Selenium WebDriver
CSS Selector in Selenium WebDriver
The below page shows that we have 3 CheckBoxes – Cricket, Movies, and Hockey.

Let us inspect the locator of the CheckBox.

Below is an example of selecting the “Cricket” and “Hockey” options in CheckBox.
*** Settings ***
Documentation To validate the Login Form
Library SeleniumLibrary
Test Teardown Close Browser
*** Test Cases ***
Select an option of Radio Button
Open the Browser with URL
Verifies page contains a checkbox
Select the checkbox options Cricket and Hockey
Unselect the checkbox option Hockey
Verify Checkbox option Cricket is selected
Verify Checkbox option Hockey is not selected
*** Keywords ***
Open the Browser with URL
Create Webdriver Chrome executable_path=/Vibha_Personal/RobotFramework/drivers/chromedriver_linux64
Go To https://demo.automationtesting.in/Register.html
Maximize Browser Window
Set Selenium Implicit Wait 2
Verifies page contains a checkbox
Page Should Contain Checkbox id:checkbox1
Page Should Not Contain Checkbox name:radiooptions #This is the locator for Radio Button
Select the checkbox options Cricket and Hockey
Select Checkbox id:checkbox1
Select Checkbox id:checkbox3
Unselect the checkbox option Hockey
Unselect Checkbox id:checkbox3
Verify Checkbox option Cricket is selected
Checkbox Should Be Selected id:checkbox1
Verify Checkbox option Hockey is not selected
Checkbox Should Not Be Selected id:checkbox3
All the below-mentioned keywords are derived from SeleniumLibrary except the last one. The functionality of keywords mentioned above:
1. Create Webdriver − The keyword creates an instance of Selenium WebDriver.
2. Go To – This keyword navigates the current browser window to the provided URL – https://demo.automationtesting.in/Register.html.
3. Maximize Browser Window – This keyword maximizes the current browser window.
4. Set Selenium Implicit Wait – This keyword sets the implicit wait value used by Selenium.
5. Page Should Contain Checkbox − This keyword is used to find the checkbox that is located on the current page.
6. Page Should Not Contain Checkbox – This keyword is used to find that the checkbox is not
locator on the current page.
7. Select Checkbox – This keyword is used to select options “Cricket” and “Hockey” of the CheckBox.
8. Unselect Checkbox – This keyword is used to unselect the option “Hockey” of the CheckBox.
9. Checkbox Should Be Selected – This keyword verifies if the checkbox “Cricket” is checked.
10. Checkbox Should Not Be Selected – This keyword verifies if the checkbox “Hockey” is not checked.
These keywords are present in SeleniumLibrary. To know more about these keywords, please refer to this document – https://robotframework.org/SeleniumLibrary/SeleniumLibrary.htm
To run this script, go to the command line and go to directory tests.
cd Tests
Step 6 – Execute the tests
We need the below command to run the Robot Framework script.
robot CheckBox_Demo.robot
The output of the above program is

Step 7 – View Report and Log
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!!