Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (120 points)

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);

});

1 Answer

0 votes
by (26.4k points)

Try the following code using Chai-as-promised:

expect(condition).to.eventually.equal(something).and.notify(next); 

Want to learn more about Java? Come and join: Core java course

For more details, do check out:

Browse Categories

...