How to use CSV files to store variables for scenario parameters?

To genuinely replicate real world impact on an application, parameterizing data is critical. In ScenarioBuilder you can access unlimited rows of data values, stored in comma separated values (CSV) files, to make each playback of a scenario a unique, real user experience.

Create a new scenario parameter CSV file

Start by creating a file that contains the values to be used for Scenario Parameters. Click the “Scenario Parameter”  icon in the ScenarioBuilder tool bar. The Scenario Parameters window opens;

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_944_Mar

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_945_Mar

Provide a name for the file and click the “Open in Excel” button in the Scenario Parameters window;

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_946_Mar

Microsoft Excel™ or other default CSV editor will open in a new window;

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_947_Mar

ScenarioBuilder gets you started by providing two column headings. Feel free to use the generic headings or overwrite them. Enter data values for the rows below the headings. Each column represents a different value to be used in a scenario. Below is a sample file containing office staff;

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_948_Mar

If using Excel, as in the above example, simply “Save” the file and it will be stored in CSV format in the current Project’s “Variables” folder. Exit Excel.

If using a text editor like Notepad, include commas between headers and values (no spaces);

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_949_Mar

Save the file and it will be stored in CSV format in the current Project’s “Variables” folder.  Close text editor.

Tip: If the editor does not automatically save the file in CSV format, use the editor’s “Save As” option and change the “Save as type” to “All Files (*.*)”; add the .csv extension to the file name and “Save”;

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_950_Mar

Edit an existing scenario parameter CSV file

Click the folder icon in the Scenario Parameters window to open the current Project’s “Variables” folder;

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_951_Mar

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_952_Mar

Double-click the desired file and it will open in your default CSV editor.

Attach a scenario parameter CSV file

Scenario Parameter CSV files can be attached at the scenario level for global access, or at the component level for access limited to the component.  Unless your intention is to have the scenario loop through a component multiple times, retrieving a new row from the CSV file with each loop, attach the file at the scenario level. To do so, highlight the scenario name (top row) in the Scenario window, and click the “Variables File Name” property.  Enter the name of the desired file, or navigate to it by clicking the “Open” icon;

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_955_Mar

In the “Variable Access Type” field select “Random” or “Sequential” to determine how values are retrieved from the CSV file;

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_956_Mar

Add scenario parameters

Now that you have created a CSV file and attached it to the Scenario, you are ready to add the Scenario Parameters. Add a “Type Text” action to the scenario. In the “Properties” pane, right click inside the “Text” field;

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_958_Mar

At the bottom of the pop-up menu, select "CSV Variable" option and click the CSV file to reveal all of the fields (column headers) from the attached CSV file. Select one of the fields.  Typing the name of the field into the Text property field (framed with percentage signs) is also an acceptable method of adding the field.

Last line used in scenario parameters CSV file

After executing a playback of the Scenario, click the “Modify CSV lines”  under the “Run” section of the tool bar to display the “Last Line Used” from the attached CSV file;

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_960_Mar

How to use CSV files to store variables for scenario parameters_ (115004791467)_ScreenHunter_963_Mar

If accessing the CSV file sequentially, edit the “Last Line Used” value to stage the scenario to retrieve a desired value from the file on the next execution (if accessing randomly, adjusting the “Last Line Used” value will not impact the next playback). 

Tip: For more about Variables actions, please check out “Use Variables Actions” in our Video Tutorials series.