Robot framework comes with a solid functionality and 3rd party libraries that others have already implemented; such as writing logs and reports, capturing screenshots, integration with continuous integration tools, support for keyword driven testing, simultaneous running and of course a connection to a variety of external libraries. All these great features allow us to focus on our product testing, instead of investing a lot of time in reinventing the wheel.
Robot Framework Vs. Selenium WebDriver
Robot framework or Selenium Webdriver? A question frequently asked in professional forums, the answer is pretty simple- “This question is irrelevant”, there is no sense in comparing the two.
Selenium is a library (some call it a Webdriver) and Robot is a test automation framework that uses libraries. With Robot, you can run a variety of automated tests; Both UI element based and API tests, you can run a test with the help of the a math library and a test that validates if the element exists on the page, with the assistance of Selenium Webdriver.
With selenium, you can create UI based functional test cases, but in order to execute them, you’ll need a test automation runner or alternatively, an automation wrapper. There are several popular test runners available out there, for instance: TestNG, Nunit, Junit etc.
How Does Robot Work?
As previously mentioned, Robot uses libraries, the following diagram describes the architecture of the environment, the orange rectangles represent the connection to the libraries (in this case to Selenium and the Database):
Supported libraries by Robot Framework (the screenshots were taken from the official site):
Robot is written in Python, which enables compatibility with a great amount of libraries. Despite the fact that, it has expansions for Java (with Jython) and to .NET as well (with IronPython).
The Multi-Dimensional Model in Robot Framework
Robot framework allows writing test automation tests (for instance using Selenium) in several dimensions:
- The first dimension is based on Selenium’s API, in this example the automation test case will look as follows:
Notice the simplicity of the code, the open browser’s command that’s presented by a single line of code. It receives 2 parameters: The name of the site to navigate to and the browser’s name. That’s all. How many lines of code would we need to write in Selenium WebDriver to produce the same action? I can tell you that, at least 5.
- The second dimension is called Keywords in which we can assemble a few steps for one function (Keyword) and then to call this function, for example, I can assemble 3 steps:
- Entering a value in the user’s field
- Entering a value in the password field
- Clicking on the Login button
This function (Keyword) will be called for example ‘Login to Site’ with the relevant parameters (values of user name and password).
- The 3rd dimension is the Page Object- through which I would map my site and divide my project into documents according to the mapping.
The page object is a design pattern, that isn’t related directly to the Robot. However, it’s possible and highly recommended to include it here as well.
- In the 4th dimension, we can use the Robot’s compatibility with Gherkin (similar to how Cucumber and SpecFlow are using it) and then write our tests as the following:
it’s also possible to implement this layer in keyword driven testing style or any other, so it will be clear enough.
The Reporting System
I do need to mention that the reporting system for this environment is not the most visually impressive I’ve ever seen. But, it’s clear, user friendly, provides all the required information (including screenshots) and doesn’t take any effort to implement.
Here is the example of a test automation output (a screenshot of a log and a screenshot of a report):
A case of a test that passed:
In a case of a failed test:
To summarise, the reporting system in my opinion, symbolises Robot in terms of how easy it is to generate it. The example presented above demonstrates how opening a browser in the Robot requires only a single line of code (instead of 5 in Selenium), logs and reports that are created automatically when executing tests, without the need to write even a single line of code. This is why in my opinion, Robot Framework is probably one of the most worthwhile test automation frameworks available in the market nowadays.