If you want to extract data from an Excel file and convert it into a JSON object, you can utilize the following package:
https://www.npmjs.com/package/simple-excel-to-json
//read.js
const parser = require('simple-excel-to-json');
const doc = parser.parseXls2Json(`Sample.xlsx`);
doc[0].forEach((data, i) => {
console.log(`${i} ${data.name} ${data.age}`)
})
The 'name' and 'age' in the code refer to the column names of the excel file.
https://i.sstatic.net/8uWgz.png
https://i.sstatic.net/mbHNb.png
After extracting the necessary values, you can concatenate them into a string with appropriate delimiters.
This concatenated string can then be written to a new file.
const fs = require('fs');
fs.writeFile("test_input.feature", /* string to be written */, function (err) {
if (err) {
console.log(err);
}
});
You have the option to include the file saving functionality within the read.js script itself.
In your Protractor configuration file, specify the directory where you intend to store the feature files.