Skip to content

Data-Driven Testing

Many test automation scenarios require performing same steps with different data. For example, login into application with different user credentials, or enter several lines of a sales order into a table. This is data-driven testing. From this article you will learn how to do this in Rapise Visual Language (RVL) and JavaScript modes. You will also learn how to define data within a test and in an external spreadsheet.

DDT in RVL

Let's start from RVL mode first. With RVL you can delegate low-level complex automation tasks to a developer team and focus on testing scenarios and data used to fill forms and tables.

Embedded Data

First, define data schema. In the Flow column of RVL spreadsheet choose Map.

Then hit Tab on the keyboard and Rapise will generate a template for the data table.

Give this new map a name and define columns and initial set of rows with values.

In our example the map has name Data and it has three columns: FirstName, LastName and Company. It also has two rows with data values.

Now in our test we can just use the map and refer to it's columns by name.

Data becomes one of parameter types.

And when Data is selected as a parameter type then column names are available in the drop down.

Now our RVL looks like this.

Execution of the test produces the report. The test simply prints first line of the data table.

The data table we just created is an object in Rapise object repository and it has actions. With actions one can manipulate active row and column index and read arbitrary data from the table.

For the detailed description of actions one can do upon data tables refer to Map Object reference.

Let's advance to next row in our table before printing values.

After execution the report displays data from the second row.

Excel Data

Now we are ready to put data into external spreadsheet. Let's create one. In the Files view right click Scripts folder and choose Create > Spreadsheet...

We'll go with default options.

Rapise has built-in spreadsheet editor and you do not need Excel to be installed on the machine.

Let's bind to this spreadsheet in RVL. Insert a line below Data map we created in previous section. In the Flow column choose Map and then set map type to Range.

Give the map same name Data and make sure that it references Data.xlsx which we just created.

Running the test. Now data is taken from the Data.xlsx. Notice that in Data.xlsx we named columns same way as in the previous section.

If we'll do a loop with Data map Rapise will iterate through all lines on execution.

DDT in JavaScript

One can read data from a spreadsheet in JavaScript mode as well. There is a global Spreadsheet object that is available in every test. Here is an example of Spreadsheet API usage.

Spreadsheet.DoAttach('Calc.xls', 'Calc Data');
while(Spreadsheet.DoSequential())
{
    EnterNumber(Spreadsheet.GetCell("Item1"));
    Operation(Spreadsheet.GetCell("Operation"));
    EnterNumber(Spreadsheet.GetCell("Item2"));

    SeS('ResultButton').DoAction();

    Tester.Assert( '' + Spreadsheet.GetCell("Item1") + 
                   Spreadsheet.GetCell("Operation") + 
                   Spreadsheet.GetCell("Item2") + '=' +
                   Spreadsheet.GetCell("Result"),
                   CheckResult(Spreadsheet.GetCell("Result")));
}

Description of all Spreadsheet actions and properties is available here.

Open UsingSpreadsheet sample test from the start page to see a working example (scroll the list of samples down).

See Also