Blog - Xray

Guide to Test Automation with Robot Framework

Written by Sérgio Freire | Jun 17, 2020 9:00:00 AM

Robot Framework is a generic open-source automation framework for acceptance testing, acceptance test-driven development (ATDD), and robotic process automation (RPA). Robot Framework allows testers to easily write automated test scripts using a keyword-driven testing approach.

In this post, we’ll go over the main concepts and benefits of Robot Framework and show how you can use it to scale your test automation by reusing and extending existing keywords.

 

What is Robot Framework used for?

In the testing context, Robot is used for teams adopting ATDD (Acceptance Test Driven Development). Broadly speaking, it can be used to automate “test cases” (i.e. scripts) no matter the moment you decide to do so or the practices your team follows.

Unlike Cucumber and other automation frameworks, Robot comes with a set of standard test libraries to ease the interaction with the operating system, provide common assertions, and more. Since it is built in Python, it can be used and further extended using Python or Java.

Astrong community around Robot continuously increases the number of available libraries and resources for Robot Framework.

Test libraries provide their own keywords; a well-known library is SeleniumLibrary that allows automation of browser interactions using Selenium/WebDriver.

 

How to write automated test scripts

With Robot Framework, you can easily write automated test scripts. Keywords are used to perform actions but also to provide assertion mechanisms. They can receive arguments as a means to condition their behavior.

As shown ahead, “Open Browser” and “Title Should Be” are some clear examples of that.  You don't necessarily need to code in Python/Java because there are many test libraries that provide the necessary bits of automation as keywords.

 
 

In the previous example, you could also depict the ability to make composable keywords that may provide an additional layer of abstraction to separate the “what” from the “how.”

Overall, Robot Framework has some key features that make writing and maintaining test cases easier:

 

Robot Framework vs. Cucumber

If all you need is a testing tool for driving a mouse and a keyboard, don’t use Cucumber. There are other tools that are designed to do this with far less abstraction and typing overhead than Cucumber.”  

Aslak Hellesøy - Creator of Cucumber

Cucumber has many different implementations in different languages (e.g. Ruby, Java, Javascript). The company behind Cucumber has meanwhile been bought, and even though it has an open-source variant, the model is substantially different from Robot Framework which is backed up by a foundation, sponsored by many different companies.

Robot Framework follows quite a different approach from Cucumber:

  • Robot is admittedly a generic automation tool;
  • Robot comes with a built-in set of test libraries and corresponding keywords;
  • Robot is built around the premise that you can write test cases without even having to code, as there are many available libraries that provide reusable keywords and its underlying code;
  • Robot covers RPA (Robotic Process Automation); Cucumber doesn’t.

Note that Robot Framework can also be used for teams that adopt BDD and test automation. It supports Gherkin syntax for specifying test scenarios.

 

Xray and Robot Framework

Xray and Robot Framework are close friends. Why? Because teams using Jira can easily track their Robot Framework test automation results in Jira and use Xray as the single-source of truth. It’s as simple as submitting the results to Xray and letting it do the rest. 

Submit results by using a CI tool (e.g. Jenkins, TeamCity, Azure DevOps, Bitbucket) or even by doing a simple POST request (with “curl”, for example).

 

How Xray supports processing Robot Framework test results

Auto-provision Tests
Avoid duplication during auto-provisioning
Import results
Detailed results
Import attachments (e.g. screenshots) Planned
Enforce results to existing Test issue (if you want)
Automatic linking to requirements
 

After a successful import, results can be tracked across Jira, mainly in the "test run" details, on the "user story" screen and also "agile boards."

 

The process of importing Robot Framework test results into Xray is easy and intuitive.  If you want to go into more technical detail, don’t miss the post: How to integrate Robot Framework with Xray.

Please share your thoughts and experiences with us in the comments, we’re always looking to understand how you use the product in real-life and how we can improve your experience. 

 
 

Want to hear first-hand from the creator of Robot Framework, Pekka Klärck, and learn how to use Robot Framework together with Xray?

 

Additional Resources