Data-Driven Test Case in Robot Framework

DataDriver is an alternative approach to create Data-Driven Tests with the Robot Framework. DataDriver creates multiple test cases based on a test template and data content of a CSV or Excel file. All created tests share the same test sequence (keywords) and differ in the test data.

Because these tests are created on runtime. Only the template has to be specified within the robot test specification and the used data are specified in an external data file.

The template is a pre-formatted file that serves as a starting point for the new document

We have already written a Flight application test case, in that we used a keyword Login to Flight application and we had actually given username and password in the test case itself. Now we have to convert this tets case into a data-driven test case by using the excel library keywords.

In the case of the keyword-driven test case, we were accessing the username and the password from the Login to Flight application keyword, but in data-driven, you are going to access this information from the excel file.

Let us create a new Excel file by the name LoginData.xls having following data and save this into Demo folder

Login-data-excel-sheet

We can access username and password value by using the Read Cell Data by Cordinates keyword which requires two parameters column count and the row count and hence the column count for username becomes 1,1 and the row count for password will become 2,1.

The Login to Flight application commonlyusedkeyword is shown below

login-to-flight-application-coreect-keyword

Go to the Ride editor and create commonkeyword LoginandnavigatetoURL which include Login to Flight application commonkeyword.

loginandnavigatetourl-keyword

Now, create a new test suite Flight Application1 and then create a new test case as TC01-Login screen-Objects. Here the first step is to log in to the ngendigital/demo-application page and hence access the keyword Loginandnavgatetourl

login-tc01-screen-objects

Select the test case and run, once the test case starts executing, it will open the flight-application login page by using the username and password which has been saved in the excel file and closes the browser.

And the Log report is:

output-of-flight-application-tc01

Locators in Selenium

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions