Then('I should varify Export file is displayed with correct Plant headers', async function () {
//Reading Data from CSV File
const papa = require('papaparse');
const fs = require('fs');
const file = fs.readFileSync('C:\\Users\\sudeep\\Downloads\\2019-09-20_plants.csv', 'utf8');
//Printing First Column (Planned LT# from the csv file)
let results = papa.parse(file, {
header: true
});
console.log("Planned LT # column Values")
for (let i = 0; i < results.data.length; i++) {
console.log(results.data[i]["Planned LT #"])
}
//Printing Entire Data from CSV file and all headers are displayed properly.
papa.parse(file, {
complete: (result) => {
let csvHeaders = result.data[0] + '';
console.log("@@@@@ Complete CSV file : " + result.data)
console.log("###### row: " + result.data[0])
console.log("****** value in a row: " + result.data[0][2])
expect(csvHeaders).equal("Plant,Ordered,Planned,Actual,Problems");
console.log("Headers validation is successfully completed");
}
});
await browser.close();
await window_handle.switchToParentWindow();
await browser.sleep(3000);
});