I am new to typescript and looking to scrape a list of values from an ag-grid column and compare it against a string array. Here is the function I wrote to achieve that. But my ActualRatingsValues.push(text); does not seem to be populating the array ActualRatingsValues. I don't really understand how promises work. Is this to do with promises ?
validateRatingsValues() {
const ExpectedRatingsValues: Array<string> = ['A', 'B', 'C', 'D', 'E'];
const ActualRatingsValues: Array<string> = [];
const wrapper = element.all(by.css('.ag-pinned-left-cols-container div[col-id="name"]'))
.getText()
.then(text => {
ActualRatingsValues.push(text);
});
let match = true;
if (ExpectedRatingsValues != null && ActualRatingsValues != null) {
if (ExpectedRatingsValues.length !== ActualRatingsValues.length) {
match = false;
} else {
for (let i = 0; i < ActualRatingsValues.length; i++) {
if (ActualRatingsValues[i].toString !==
ExpectedRatingsValues[i].toString) {
match = false;
break;
}
}
}
} else {
match = false;
}
expect(match).toBeTruthy();
}