An introduction to
Robot Framework
AGENDA:
Introduction to Robot Framework
Installation
Libraries (External Libraries, Built-in and Tools)
High Level Architecture
Script Architecture: Creating Variables, keywords, Testcases and Importing Libraries
Framework Implementation
Fla UI Concepts for Desktop Automation
Executing Test Cases
Results and Reports
CI/CD Integration
Why Robot Framework and limitations
Q&A
What is Robot Framework ?
Open source, Python based; keyword driven automation framework
Various generic libraries supports heterogenous environment
Integrates with other tools for complex automation without licensing
fees
Platform and application independent
Has Built-in support for Variables
Provides tagging to categorize and select test cases to be executed
Test-case and Test-suite level set up and teardown
Installation:
Install Python from https://www.python.org
Add python to path during installation
Installing Robot Framework with pip:
pip install robot framework
Install a specific version
pip install robot framework == 7.0.1
Verifying Installation
robot --version
High Level Architecture:
When test execution started, framework first
parsed the test data
The core of the framework does not know about
SUT and interaction is handled by libraries
Libraries can either use interfaces directly or
use low level test tool as drivers
Test execution is started from the command
line and at the end of execution, report and logs
gets generated
LIBRARIES (EXTERNAL LIBRARIES, BUILT-IN AND TOOLS)
External Libraries:
Selenium Library : uses popular selenium tool internally
Browser Library: testing Library powered by Playwright
Appium Library: android and iOS testing
Database Library: database testing
Robot framework Flaui: for windows application
ScreencapLibaray: taking screenshot and video recording
There are many more and can be installed based on needs. User can create
libraries and import too
• Built-in Libraries:
• Builtin: generic keywords, automatically available without imports
• Collection: handling python lists and dictionaries
• DateTime: data and time conversions
• Dialogs: pausing the execution and getting input from users
• Licdoc: keyword documentation
• OperatingSystem: enables various operating system
• Process: running processes in the system
• Tools:
• RIDE: Standalone Robot framework test data editor
• Pabot: A parallel executor for Robot Framework tests and tasks
• Robot: Lightweight web server provides access to robot framework
• Hub: Framework test assets via browser
Test Script Architecture:
*** Settings ***
Library ABC
*** Variables ***
${System} Test
*** Test Cases ***
Valid login
Invalid login
*** Keywords ***
Valid login
Click ${System}
Invalid login
Click $
{System}
*** Settings ***
Import libraries
Library libraryName arg1 arg2..
Import External Keyword resources
Resource
../../keywords/myKWords.robot
Setup and Teardown
Suite Setup My Suite Setup Keyword
Suite Teardown My Suite Setup
Keyword
Test Setup My Test Setup Keyword
Test Teardown My Test Setup
Keyword
Documentation
Details about script
*** Variables ***
*** Variables ***
${NAME} Robot Framework
${VERSION} 2.0
${ROBOT} ${NAME} ${VERSION}
*** Variables ***
${NAME} = Robot Framework
${VERSION} = 2.0
*** Variables ***
${EXAMPLE} This value is joined
... together with a space.
${MULTILINE} First line.
... Second line.
... Third line.
*** Variables ***
@{NAMES} Matti Teppo
@{NAMES2} @{NAMES} Seppo
*** Keywords ***
*** Keywords ***
Create a Action code
wait until keyword succeeds 10x 500ms Element Should Exist $
{System}
Focus ${System}
Click ${System}
Focus ${Registermain_xpath}
@run_keyword_variant(resolve=2, dry_run=True)
def wait_until_keyword_succeeds(self, retry, retry_interval, name,
*args):
"""Runs the specified keyword and retries if it fails.
*** Keywords ***
Compare the text value
${Text} Get Text From Textbox ${Notepadtexteditor}
Should Be Equal ${Text} ${Actionname}
def should_be_equal(self, first, second, msg=None, values=True,
ignore_case=False, formatter='str', strip_spaces=False,
collapse_spaces=False):
Resource File
A resource file is a file that Example of Resource File:
contains reusable keywords, *** Settings ***
Library OperatingSystem
variables, and other settings that
can be used across multiple test *** Variables ***
${EXPECTED_YEAR} 2015
cases or test suites.
Resource files are used to *** Keywords ***
Check Host Date Is
organize and centralize common
[Documentation] Check date...
functionality and reduce ${host_year}= Get Time year
Should Be Equal ${host_year} $
duplication of effort in test
{EXPECTED_YEAR}
automation.
No *** Test Cases *** section in resource
files !
Framework Implementation
Introduction of FLA UI Inspect Tool
FlaUInspect acts as a visual inspection tool specifically designed for UI elements
within Windows applications.
It allows you to explore the UI structure of an application, examine the properties
of UI elements, and understand how they are exposed to automation tools like
FlaUI.
Installation of FLA UI Inspect Tool
Pre-requisites:
Chocolatey (Package manager for windows)
Fla uI inspect is provided as a package inside chocolatey package manager
Installation:
Open command prompt as administrator and install chocolatey using the following
command
https://chocolatey.org/install-> copy the command
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -
NoProfile -InputFormat None -ExecutionPolicy Bypass -Command
"[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object
System.Net.WebClient).DownloadString('https://community.chocolatey.org/inst
all.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin“
FlaUI Installation: choco install flauinspect
Inspect Element Using FLA UI
Executing Test Cases
Robot Framework Test cases are executed by
command Line with different options and end result
is output file in XML format and HTML report with logs
For single test case:
Robot tests.robot
robot path/to/my_tests/
For complete test suite
robot *.robot
For particular test only
robot -t “testcasetitle” .
User wants to change the name of log and report file
robot --logtitle Logs --reporttitle Report tests
/Action/PAT20761.robot
Results And Logs
CI/CD Integration
Execute Windows Batch Command
Build with Parameters
Results
Robot Framework-Pros and Cons
Advantages: Disadvantages:
Easy To Use: require little or no Limited support: not enough support
programming experience of non-ui testing
Extensibility: wide range of test libraries Database Testing: not able to perform
any testing for database
Cross Platform Support: runs on windows,
Linux, os… Complex Test cases: test cases having
high level of customization
Integration: Integration with other tools
such as selenium, Appium, Jenkins and many
more
Reporting: Detail report on Test execution,
easy to fix issues
References
https://gdatasoftwareag.github.io/robotframework-flaui/keywords/1
.5.1.html
https://robotframework.org/robotframework/latest/libraries/BuiltIn.
html
https://robotframework.org/robotframework/latest/RobotFramewor
kUserGuide.html#getting-more-information
https://rticau.github.io/ScreenCapLibrary/ScreenCapLibrary.html#P
ause%20Video%20Recording
https://robotframework.org/
Q&A