how to create and use CSV file for data-driven testing

Asked by keyu ruan

There is statement in URL : :

You may optionally create a data file for data-driven testing. Create a ‘^’ delimited txt data file with the same name as the test, plus the ‘.csv’ extension. This will run a test using each row in the data file (1st row of data file is variable name mapping)

Could you list the detail steps regarding how to use this feature? Cause I did add the file and runner is able to recogonized it. But I do not know how to use the data in the file from code perspective. Could you give a example? Thanks!

But the way, Is there a best practical regarding how to orginize test data like: object id or xpath, test case relate data?

Best Regards,
Keyu Ruan

Question information

English Edit question
selenium-simple-test Edit question
No assignee Edit question
Solved by:
keyu ruan
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Corey Goldberg (coreygoldberg) said :

Say you have a test script named "", and would like to read data values from a text file.

You would create a file named "mytest.csv". This file contains a header row, and rows of data values. Values in each row are separated by a "^". The associated test script will run once for *each* row in the file, using the supplied data values.

Here is an example.

Below I define 2 columns (url, title) and supply 3 rows of data (containing a url and title each). The test script ( would run 3 times. Each time through, it would load another row of values (from mytest.csv) that will be available inside your test script.

data file - mytest.csv:

test script -
from sst.actions import *

hope that helps..


Revision history for this message
Corey Goldberg (coreygoldberg) said :

posted an answer

Revision history for this message
keyu ruan (keyu-ruan) said :

It did help, I am able to use this feature in the framework now. Thanks a lot.