The term “Automation” is one of the biggest buzzwords that is heard everywhere today and the key to the future world. Test automation has become an indispensable part of modern software development practices because of the frequency of new releases. Manual testing takes up physical time and effort to ensure the software code does everything that is expected of it. If you are familiar with manual testing, you know how extremely time-consuming and repetitive this process can be.
What is robot framework?
Robot Framework is a generic open-source automation framework which can be used for test automation and robotic process automation (RPA). It is open and extensible and can be integrated with almost any other tool to create robust and flexible automation solutions.
Robot framework works well on all the Operating Systems available. It is built on Python and runs on Jython (JVM) and IronPython (.NET).
One of the advantages of choosing Robot Framework over other testing frameworks is the easiness that it offers. It allows businesspeople to write their own test-cases without any prior programming knowledge.
Robot framework features
- Tabular format for testcases
- High level architecture
- Single tabular syntax
- Data driven testcases
- Acceptance testing
- Separate test data editor
- Clear reports
- Detailed logs
- Generic test libraries
- Keywords
- Variable
- Libraries
- Resources
Robot framework Architecture
Robot framework is built on a modular architecture that can be extended with bundled and self-made libraries. When execution is started, the framework first passes the data. It then utilises keywords provided by the libraries to interact with the target system. Libraries can communicate with the system either directly or using other tools or drivers.
Test or task execution is started from the command line. As a result, you get a report and login html format as well as xml output. These provide an immense insight into what your system does
Robot framework – Uses in our industry
In a web development scenario, the QA team runs multiple tests on its products and strives to detect the defects before the initial release. But the fact is even with the best manual testing these bugs crawl in and often reappear and are mostly detected much later after the web solution is delivered. Automated web testing is the best option to boost the efficiency of software testing.
Robot Framework is written in Python and is a keyword-driven test automation framework. It empowers testers to manage and automate complex workflow scripts efficiently.
Installation
Environment Setup
-
Python
- https://www.python.org/downloads/
- Download the latest version from the above link and install.
The default location of Python is C:\program files \Python
-
Pycharm IDE
- Pycharm is an Integrated Development Environment (IDE) used in computer programming, specifically in python language
https://www.jetbrains.com/pycharm/download/- Download Pycharm from the above link.
- Pycharm is an Integrated Development Environment (IDE) used in computer programming, specifically in python language
Install Robot Framework API Testing Libraries
- Install following libraries using Command prompt
- Robot framework
- Run the command pip to install robot framework.
- Robot framework
-
- Requests
- Run the command “pip install requests to install requests”.
- Requests
-
- Run the command “pip install Robot framework-requests” to install robot framework-requests.
-
- Run the command “pip install Robotframework-jsonlibrary” to install Robotframework-jsonlibrary
- Go to Pycharm File – Create New project – Give the project name
- Add Libraries
- Robot framework
- Requests
- Robotframework-requests
- Jsonpath_rw
- Jsonpath_rw_ext
- Robotframework-jsonlibrary
These libraries can be added to the projects in the below manner:
- File – Settings – Select your project – Project interpreter
- Click on Add button and search for the library eg: Robot framework
- Select the libraries and click install package.
- After installing the libraries, they can be found in the project interpreter window inside the Pycharm.
Rest API automation using Robot Framework
REST API Testing is an open-source web automation testing approach used for testing RESTful APIs for web applications. Rest stands for Representational State Transfer which is an architectural style for designing loosely coupled applications over HTTP and an approach for communication and data exchange used in the development of web services.
Write first testcase – Get Request
- Create new project-Test case
- Send Get Request
- Pick and Display Response
Testcase file divided into different sections
- Settings
- Add request library into the settings section
- Variables
- Enter the base url
- Testcases
- Enter testcase name and create body of testcase
- Using the create session keyword and enter name of the session + base url
- For getting response – Get request + session name + relative url
- Eg:- $(response) = get request Get_ Student_ Details api/studentDetails
- For viewing the response use the command –
log to console $(response)
- To view the content of the response, use the command –
log to console $ (response .content)
Steps in the above example:
- Copy the base URL into the variable session then move on to testcases and give name to the testcase (TC_001_Get_Request)
- Create session with name (Get_Student_Details) and add to base URL
- Create get request and add relative url
- To print the response variable (response.status_code)
Robot framework Advantages
- It is an open-source framework
- Cool and easy to learn
- Tabular format for testcases
- Data driven testcases
- Keyword-driven testing approach
- Robot framework is application and platform independent
- It is a good support for external libraries. Most used is Selenium Library, which is easy to install and use in robot framework
- User doesn’t need programming languages to write a robot framework testcase and run
Robot framework Limitations
- Less flexibility
- Lack of parallel test execution
- Lacks support for if-else and nested loops, which can be useful when the code gets complex
Robot Framework and Selenium WebDriver
Selenium WebDriver being one of the most widely used tools for performing automation testing if integrated with Robot Framework can work wonders and yield a robust automated website testing tool. To make use of the full potential of Selenium, Robot Framework internally incorporates Selenium WebDriver functionality.
To conclude Robot Framework has evolved to become a generic, easy-to-understand open-source framework that provides a modular interface to build custom automation test cases, immensely useful to testers and developers alike.