I currently have two methods like this:
getCell(lineItemRow, columnName) {
return this.getColumnIndexOfColumn(columnName)
.then(function(columnIndex) {
sleep(10000);
return new Element(`//div[@class='ember-view scrollableTableRow'][${lineItemRow}]//div[@class='scrollableTableCell '][${columnIndex}]`)}
);
}
getColumnIndexOfColumn(columnName) {
let b = this.browser;
return this.getColumnTitles()
.then(function(columnTitles) {
let titles = columnTitles.value.map(function(element) { return b.elementIdText(element.ELEMENT) });
Promise.all(titles)
.then(function (results) {
var formatted = results.map(function(title) {return title.value;});
return formatted.indexOf(columnName);
}).then(function (value) { console.log(value); return value; })
})
}
The problem I'm having is that when getCell calls this.getColumnIndexOfColumn(columnName), the value that is resolved is undefined, rather than being the proper index. I can verify that the formatted.indexOf(columnName) call returns the correct index. How would I make getColumnIndexOfColumn resolve with the value of formatted.indexOf(columnName)?
Thanks