Data Driven Testing in Robot Framework
Technical Feed
Nisha T S May 22, 2018

A Short Introduction to Robot Framework

Robot Framework is a generic open-source test automation framework suitable for end-to-end acceptance testing and acceptance test-driven development (ATDD). Also, data driven testing in robot framework is a topic that’s worth discussing and understanding.

So, the test syntax for Robot Framework follows a tabular style and plain text format, making writing test cases more user-friendly and easy to read. Therefore, Robot Framework was found to meet all the required requirements in testing. One of the other benefits of Robot Framework is that it is created in Python, which can be implemented on all major platforms.

Among the other open-source tools; Robot Framework is an example of the very few tools that support a multi-platform environment. The test data in Robot Framework is simple and easy to edit, so it’s convenient to store in any version of the control system. Now, let’s move on to data-driven testing.

Also Read: Automation Challenges and Solutions – Robot Framework

Data Driven Testing in Robot Framework

What is Data-Driven Testing?

Data-Driven Testing is a test design and execution method where the test scripts read data from sources such as XLS, XML, and CSV files rather than utilizing hard-coded values. This strategy allows the automation engineers to implement a single test script that can execute tests for all the test data in the table.

The tasks in testing services, such as quality assurance, sometimes require developers to examine how different “classes” of data will perform in the same test procedure.

A perfect example is when users must log in with their email credentials to access a website. The general way to test this case scenario is to give a valid email and password and then click the submit button.

The expected result is that the user logins to the system under test, but several negative testing scenarios also need to be covered. 

Such as:

A) Valid email, invalid password = Error message 1

B) Valid email, blank password=Error message 2

C) Blank email, blank password= Error message 3

D) Unregistered email, valid password= Error message 4

The above scenarios would require a tester to create four different test cases and test each one of those cases individually. Since all the users are effectively following the same procedure, submitting after providing the right email and password, the tester could loop through a series of data values in the same test case and keep track of which one passes the test and which one fails.

The Relevance Of Data-Driven Tests In Data Setup

Now that we’ve explored some of the ways data-driven tests can benefit in testing, there are other instances as well where data-driven tests are implemented in data setup.

For implementing data-driven tests in data setup, we could use the same concept of iterating through different data rows to do the setup. E.g., When the development team deploys a new instance of an application under test, Jenkins could be used to trigger a particular scenario. This scenario could be a data-driven process executed to register 100 new users into the system under test from an external file like CSV, JSON, or Excel.

Therefore, whether you are doing a testing scenario, verifying the different types of users, or doing a data set-up, understanding how the robot framework can load up multiple rows of data from the file and process them through 1 test case is a great skill to have.

Here is a typical example of a test automation project that has three separate test cases for testing the negative condition

Data Driven Testing in Robot Framework (three separate test cases testing the negative condition)

As you can see:

  1. In the first test case, unregistered users should be able to view the correct error message at login. 
  2. In the next test case, registered user logins with an invalid password should view the correct error message.
  3. Finally, if a user attempts to log in with a blank email and password, it should show the correct error message. 

Here you can see that the test cases do exactly the same test steps but with different data in each one.

The repeated test steps here are:

  1. Navigate to the Sign-in page
  2. Attempt a login with some credentials
  3. Verify that the error message displayed on the login page matches the message we would expect when we provide input data.

Also Read: How to successfully set up CI/CD in Robot Framework

Though we could test these scenarios in three different cases, a better approach would be to create a single test case that would say a negative login scenario should produce correct error messages. This would further iterate through the different data sets for the same test step in the first test case. If one of them failed, we wouldn’t exit the test case and simply keep track of the test case and then move on to the next row of data.

Here is a sample program on how you could achieve this

Data Driven Testing in Robot Framework (Test case)

Data Driven Testing in Robot Framework (test case 2)

Execute the *.robot program, and the HTML results can be viewed as below.

Data Driven Testing in Robot Framework (HTML for *.robot programme)

Data-driven tests in the robot allow you to view each test data as a separate test case in the log files.

Built-in Method for Getting Data-driven Results 

Typically, the built-in method for getting data-driven results in a robot framework is as follows:

  1. Create a keyword with the common step, either in the Tests file or the  keyword file
  2. It has [Arguments] to catch test data
  3. Add [Test Template] to the test case
  4. Associates the keyword having common steps
  5. Add data rows to the test case
  6. These will be passed into the keyword[Arguments]

Also Read: The Automation Challenges and Solutions in Robot Framework

Data-driven testing is a great alternative if your enterprise has huge volumes of data to test for the same scripts. At ThinkPalm, our test automation services ensure that your product or software’s quality, reliability, and performance are thoroughly verified before deployment.

Most Popular Questions

Question: Is Robot Framework BDD or TDD?

Answer: Robot Framework is a Python-based, extensible, and keyword-based automation framework for acceptance testing, acceptance test-driven development (ATDD), behavior-driven development (BDD), and… robotic process automation (RPA).

Question: What Is Meant By Data Driven Testing?

Answer: Data Driven Tests (DDT) are data external to functional tests that is loaded and used to augment automated test cases. You can take the same test case and run it with as many different inputs as possible. It will give you better coverage with a single test.

Question: Why Is TDD used?

Answer: Test driven development is becoming more prevalent, and there is good empirical evidence that it is beneficial. TDD reduces errors in production and improves code quality. In other words, it makes the code easier to maintain and understand.

Data-driven testing is a great alternative if your enterprise has huge volumes of data to test for the same scripts. At ThinkPalm, our test automation services ensure that your product or software’s quality, reliability, and performance are thoroughly verified before deployment. 

Connect with us to schedule a free consultation about Testing as a Service (TaaS), Software Testing Services, or Test Automation Services.

Let's Talk


Reduce testing time by 70% and ensure you deliver high-quality products!



Reduce testing time by 70% and ensure you deliver high-quality products!