I have a download link on a webpage which downloads a csv file. This csv file contains 100+ columns with data (numeric, text, decimal etc). The values in csv are actually taken from the webpage entered by users, when user clicks save and clicks download link these values are downloaded to csv.
How do i write a nightwatch test which can validate all of these values from web page are downloaded to csv correctly?
I have mapped all the values (that go into csv) from webpage into UI properties (such as cityName:'input[elementId]', stateName:'input[elementId]' ..so on).
I am looking for a way to perform below steps in my nightwatch tests:
Step1> Get all the values from the UI for ex: browser.getValue(cityName,function(textBoxValue){
var city=textBoxValue})
Step2> Trigger Click download link
Step3> Read the downloaded file from CSV and compare the value in csv with that of the value in UI - pass if the csv value and UI value match.
Any help would be of great use. Thanks in advance.
const papa = require('papaparse');
const fs = require('fs');
..
..
fs.stat(localFilePath, function(err, stats){
if (!err) {
var fileContents = fs.readFileSync(localFilePath, 'utf8');
papa.parse(fileContents,{
complete:function(results){
city = results.data[1][1];
state = results.data[1][2];
done()
}
});
}