-
Notifications
You must be signed in to change notification settings - Fork 104
Data driven Testing
In Builder, you can play back tests on the basis of rows of data. Each row of data is a test run. The data values are put into playback variables, so for example, the script
print ${varname}
with data rows of
varname
-------
foo
bar
baz
will run the script three times, printing foo
, bar
and baz
.
You can set up a script for data-driven playback through the Data menu in Builder. With Selenium 2, the data-driving settings are saved in the script JSON file.
Support for this new feature in the Java and node interpreters is currently in the works.
The following data sources are currently supported:
The default. Equivalent to a single row with zero columns.
A single data row stored directly in the script. Useful for testing.
The data is stored in a JSON file, the path to which is stored in the script. The JSON structure is an array of objects, one per row. For example:
[
{ "varname": "foo" },
{ "varname": "bar" },
{ "varname": "baz" }
]
The data is stored in an XML file using the same format as data-driven playback in Selenium IDE. For example:
<testdata>
<test varname="foo" />
<test varname="bar" />
<test varname="baz" />
</testdata>
The addition of this feature raises the version number of saved Selenium 2 JSON files to 2. Here is an example exported script:
{
"type": "script",
"seleniumVersion": "2",
"formatVersion": 2,
"steps": [
{
"type": "print",
"text": "${varname}"
}
],
"data": {
"configs": {
"json": {
"path": "/Users/zar/Desktop/mydata.json"
}
},
"source": "json"
},
"inputs": []
}