Applies to LoadNinja 1.0, last modified on October 31, 2018

Why use databanks in tests?

The test runner simulates test events using hard-coded parameter values, that is, the values that you entered during the web test recording or editing.

You may want to run your test on other data to get larger coverage and check how your web application works with different input values. Of course, you can record a number of web tests each entering different data. An easier solution, however, is to use some file as a data source (or databank), read it row by row, and run test commands for each row in that databank. Such tests are called data-driven load tests.

Databank formats

The databank must be a CSV or TXT file, with either commas or tabs as a value delimiter. The first line may contain column headers.

How it works in LoadNinja

To create a data-driven load test in LoadNinja, attach databanks to individual web tests that your load scenario will run. Then, map databank columns to event parameters as explained below. Currently, you can parameterize only the Keyboard Input events this way.

During the load test execution, each web test will typically run several times. For each iteration, LoadNinja will select a databank row randomly and will insert column values from this row into event parameters:

Data-driven testing with LoadNinja: Using data rows in test iterations

Click the image to enlarge it.

Depending on the number of iterations and the number of rows, some rows may be used more or less frequently than others. If the number of iterations is significantly larger than the number of rows, each row will be used approximately the same number of times.


  • Each test can use only one databank.

  • Databanks are not shared among web tests. To use the same databank in another test, attach it to that test separately.

Attach a databank to a web test

1. Prepare the databank

Create a .csv or .txt file with the desired data, using either commas or tabs as value delimiters. You can create the file in any text editor. Many spreadsheet applications such as Microsoft Excel, Numbers and LibreOffice can also export data to CSV.

Tip: We recommend that the first line contains descriptive column headers. In this case, the test will display the column names rather than indexes (1, 2, …).

2. (Optional) Record a web test

If you do not have a test yet, record it. Replay the recorded test once to make sure it works correctly.

3. Import a databank

  1. In the web test editor, click  Upload Databank:

    Upload Databank

    Click the image to enlarge it.

  2. In the dialog, browse for your .csv or .txt file and specify the parsing options:

    • First row contains – select Headers if the first line contains the column names, otherwise, select Data.

    • Column delimiter – select Comma or Tab depending on what is used in your file.

    Import Data Bank

    Click the image to enlarge it.

    Click Next: Review.

  3. LoadNinja will display a preview of the data. If the data does not look right, click Back and change the parsing settings.

    Import Data Bank: Preview

    Click the image to enlarge it.

    Click Next: Map Data to Script.

  4. For each input event, select the databank column from which the input values will be taken during the playback, or select No Mapping to use the hard-coded recorded value.

    Tip: You can change these mappings at any time later.
    Import Data Bank: Map Values

    Click the image to enlarge it.

  5. Click Save.

LoadNinja will upload your data file to the cloud and update the test. Events that use values from a databank will have the corresponding label:

A web test event that uses a databank

Change event-to-data column mappings

To change the databank columns used for events, you can either use the  Modify Databank command, or edit the event parameters directly.

For all events

  1. Click  Modify Databank on the toolbar.

    Modify Databank
  2. Update the mappings as required and click Save.

For a single event

  1. In the list of test steps, find the Keyboard Input event you want to parameterize.

  2. Expand the event parameters and click .

    Mapping values: Start

    Click the image to enlarge it.

  3. Select or unselect the Use Dataset check box as required.

  4. If Use Databank is selected, select the databank column to take the parameter value from.

    Mapping values: Select the databank column

    Click the image to enlarge it.

  5. Click Submit.

In Mocha scripts

When you attach a databank to a web test, LoadNinja updates the Mocha code of this test accordingly. While it is not possible to edit the Mocha code in LoadNinja directly, knowledge of databank-related statements can be helpful if you wish to reuse this code in external testing tools.

The databank is put into an array. The array name (DS_test_data in the example below) consists of the DS_ prefix followed by the name (without extension) of the databank file.

let DS_test_data = [
    {"Name":"Mark Twain", "Password":"Password1"},
    {"Name":"Maria Gripe", "Password":"Password2"},
    {"Name":"Jules Verne", "Password":"Password3"},
    {"Name":"Leo Tolstoy", "Password":"Password4"},
    {"Name":"Jhumpa Lahiri", "Password":"Password5"}

Array items correspond to the databank rows. Each array item is an object where the keys are column names and the values are column values. If the databank file does not include column names, LoadNinja uses numbers as column names: "1", "2", and so on.

The code then picks a random row number to be used during the test. Here, 10 is the total number of databank rows; your databanks may have a different number of rows.

let random_test_data = generateRandomNumber(10);

Test events that are connected to the databank will use the values from the specified data row. Here, "Name" is the databank column mapped to this event.

let test_data1 = DS_test_data[random_test_data]["Name"]; // Get the value
await driver.sendKeys(test_data1); // Use the value

See Also

LoadNinja Documentation

Highlight search results