Skip to content
Get Free Trial

Loop Through a Test Data File

Attach a test data file to a test case or keyword, so it runs once for each row of data.

Sometimes you want specific values, not generated ones, such as quantities with a known total. Put them in a test data file (.csv), one row per test run, and attach the file to a test case or a keyword. Sahi Pro then runs it once for each row.

On this page, you run the Buy Books test case with three sets of quantities.

  1. In the No-Code Test Editor, select the Add Books keyword, and click Parameterize.
  2. Select the three steps that enter the quantities, and the step that checks the total.
  3. Name the parameters $javaQty, $rubyQty, $pythonQty and $total, and click Apply.
  1. Select the Buy Books test case, the one that should loop through the data, and click Data Drive.

  2. In the Data Drive dialog, choose New File.

  3. Name the test data file books_data, and name its group quantities. A test data file keeps its rows in groups.

  4. Add a column for each parameter, and one row for each test run. Name each column after its parameter, without the $:

    javaQty rubyQty pythonQty total
    2 3 1 1550
    1 0 0 300
    0 4 2 1500
  5. Click Confirm.

To loop through only one keyword instead of the whole test case, attach the file to that keyword.

Run the Buy Books test case. Sahi Pro runs it three times, once for each row, and the report shows a result for each row.