I'm attempting to dynamically click on a cell within a row by passing the text of the cell. Here is my code:
await element.all(by.xpath('//div/table/tbody/tr')).then(rows => {
rows.find(row => {
return row.all(by.tagName('td')).filter(async elem => {
await elem.getText().then(text => {
return text === cellValue;
});
}).click();
});
});
I thought this code would work for me, but unfortunately it always clicks on the first row and does not go inside.
return row.all(by.tagName('td')).filter(async elem => {
No errors are thrown either. Any ideas on what I might be overlooking?
Update - The following code is now working for me:
const rows = await element.all(by.xpath('//table/div/table/tbody/tr'));
for (const row of rows) {
const columns = await row.all(by.tagName('td'));
const actualCellValue = await columns[columnIndex].getText();
console.log(':::cell text:: ' + await columns[columnIndex].getText());
if (actualCellValue === cellValue) {
clickWhenAvailable(columns[columnIndex]);
break;
}
}
}
Sample HTML Table Cell -
<td _ngcontent-c30="" class="mat-cell cdk-column-Company mat-column-Company ng-star-inserted" mat-cell="" role="gridcell> VAX - ABC </td>