Add external data | Tutorial
Watch this short video to learn how to insert context variables from a Microsoft Excel or .csv file to be able to run the same test multiple times in parallel with different values, also referred to as parameterized testing. This method of adding data to your test has the added value of enhanced security because you keep the data separate, out of the cloud, in an external file.
You can use context variables with every action that requires data input, such as keyboard input or navigating to a location.
For your convenience, we have also listed the steps for the main procedures below the video.
The file is limited to one sheet, and each test can only reference a single file.
- In Excel, in the first row, enter the variable names. Each variable designates a column, for example firstName in the first field of row 1 and lastName in the second field of row 1.
-
In the following rows, enter the different variable values. For example: Add Albert in the first field of row 2 and Einstein in the second field of row 2. Then add Jane in the first field of row 3 and Goodall in the second field of row 3.
Each value row indicates a test run, so if you have 2 rows, the test has 2 parallel runs.
- Save the file.
- On the canvas, in Basic mode, select the step you want to edit.
- On the right, make sure the Keys to send field is blank.
- Below the field, click Add variables and then select Context variable. The value {{variable_name}} appears in the Keys to send field.
- In the Keys to send field, replace variable_name with the name of a variable configured in the Excel file. In our example, this can be firstName or lastName.
- Repeat these steps for any other variables you want to use in your test.
If you run the test manually, the data file is not saved anywhere, so you need to select it again at each run. As an alternative, you can create a job and schedule a run, which allows you to upload the data file ahead of time. Or, if you work with CI/CD, you can configure the file path through the -n parameter. Both of these options add convenience but decrease security.
- On the canvas, click Run.
- In the Run Test dialog box, click Upload data file.
- Browse to the file, select it, and click Open.
- In the Run Test dialog box, click RUN. The test now runs in parallel execution. You see the real-time run of one execution. When all executions are complete, you can watch a video of each individual execution.
You can only create schedules for jobs, so make sure the test that requires the external data file is part of a job.
- At the top left, click the menu icon and select Jobs.
- In the Jobs view, select a job.
- In the view for the job you selected on the Schedule tab, click Add schedule.
- In the Add schedule dialog box, provide a name, the environment, target platform, repeat interval or time, and run days.
- Click Upload data file.
- Browse to the file, select it, and click Open.
- Click ADD.