I am trying to grab an elements inner text and write the inner text to a file however i am having no success. the program runs and writes to csv file but just writes the what the global variable equals instead of the inner text of the element this is what I have done:
Config file with globals:
it('Get CycleStatus, Paydate, Weeknumber, Clientid - completed', function () {
//https://stackoverflow.com/questions/44362880/protractor-if-else-with-expectcondition
var cycle = $('#cycleStatusID');
browser.wait(EC.elementToBeClickable(cycle), 20000).then(function() {
cycle.getText().then(function(text){
if (['Cycle Complete',
'Entering Payroll Information',
'Correcting Input',
'UnderReview'].indexOf(text) >= 0) {
cycleStatus= text;
console.log(cycleStatus+ ' - Displayed');
} else {
cycleStatus= 'Cycle unknown';
console.log(cycleStatus);
}
});
});
var fs = require('fs');
fs.appendFile('/Users/hoflerj/Desktop/Protractor/WFN/psreport.csv',cycleStatus, function (err) {
if (err) throw err;
console.log('write complete!');
});
});//spec function
seems like it is writing before it is actually storing the info in the variable it should be Entering payroll Information then say write complete.
problem it is writing to file but putting it in all one column.
const fs = require('fs');
const cycle = $('#cycleStatusID'); // cycle status
const client = $('#clientID'); // clientid
const writeValueToFile = (value) => {
return fs.appendFile('/Users/hoflerj/Desktop/Protractor/WFN/psreport.csv', value + ";" + "hellow world", function (err) {
if (err) throw err;
console.log('write complete!');
});
}