I am very new to TypeScript and protractor and would like to put all the extracted values from a drop list inside an array so that I can validate it from another page.
export class AdditionalCostPage extends BasePage {
getAllUsageCategoryElements() {
var usageCategory: string[] = [];
element
.all(
by.xpath(
"//p-dropdown[@name='usageCategory']/div/div[3]/div/ul/li[*]/span"
)
)
.each(function(element, index) {
element.getText().then(function(text) {
console.log('list text from drop list is ' + text);
usageCategory.push(text);
});
});
console.log('Size of the array is ' + usageCategory.length);
}
}
In the result the size of the usageCategory is 0 and also I noticed that the size 0 is printed before "console.log("list text from drop list is " + text);" gets executed. Please suggest anyone. Thanks in Advance.