I just want to know that whether this approach is good or not while using chai-as-promised with mocha and protractor?
let options = customers.all(by.tagName('option'));
options.then(function (items){
for(let i=0 ; i<items.length ; i++){
items[i].getText().then(function(txt:any){
if(txt == "ABC XYZ"){
items[i].click();
}
})
}
});
First of all you should learn more about chai plugin chai-as-promise. Visit This url to know more about this plugin.
Second you need to understand that this plugin is meant for handling assertion statement that has dependency on some promise. It is not meant for dealing all the promises. If you are new then you should learn using async/await with protractor. Refer this post for more details first source second source