Reputation: 11
let datesInColumns: string;
for(let i=1;i<totalRows;i++) {
datesInColumns = await element.all(by.tagName('tr')).get(i).all(by.tagName("td")).get(0).getText();
}
console.log(datesInColumns , 'list of data taken from the table');
So here is what am trying with the code
i want to get the column information from the table,everytime the for loop runs the new data retrieved is being stored in datesInColumns. right now this is how it looks
consider the table contents are 1,2,3,4. so am expecting the datesInColumns to store all the values ie, 1,2,3,4. Right now it is storing the recently executed for loop data ie, 4. Could someone suggest me how to store all these values in a variable everytime the for loops executes? **
Upvotes: 0
Views: 41
Reputation: 1004
You should add elements to your array by using push method on each for loop cycle. Or you can use += operator to add values to the string
const datesInColumns = [];
for(let i=1;i<totalRows;i++) {
const date = await element.all(by.tagName('tr')).get(i).all(by.tagName("td")).get(0).getText();
datesInColumns.push(date);
}
console.log(datesInColumns.join(',') , 'list of data taken from the table');
Upvotes: 1