Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is data driven testing possible with protractor?

What I would like to achieve is for the Protractor tests to extract data from a separate data file (e.g CSV, JSON, etc) so that I could change the data without having to touch the test script code.

Is this possible with Protractor?

like image 231
Rusty Wizard Avatar asked Aug 27 '14 04:08

Rusty Wizard


1 Answers

You can use browser.params to read custom test data.

To read from a JSON file simply add params to your config file

exports.config = {
  params: require('./your-params-file.json'),
};

NodeJS will automatically convert the JSON file to a Javascript object that is easily accessible from any of your tests through browser.params.whateverYourJSONHas.

If you really need to use CSV then try some parser like csvtojson or google / open another question about "NodeJS convert CSV file to array of POJOs"

like image 163
Leo Gallucci Avatar answered Sep 22 '22 01:09

Leo Gallucci