Could someone please assist in troubleshooting my code? I am trying to select a specific value from a dropdown list but is encountering difficulties. The code is able to retrieve the values from the dropdown but is unable to successfully click on the matching value. Any help would be greatly appreciated. Below is the code in question:
async getDropDownHeaderMenu(selectedOption:string){
let headersCols = element( by.css('#abc'));
await browser.wait(until.presenceOf(headersCols), this.DEFAULT_WAIT_TIME_SECONDS * 1000, 'failed to find dropdowns!');
headersCols.click();
let valuesSet: Set<string> = new Set();
let promisesArray = [];
return new Promise((resolve, reject) => {
element.all(by.css('div.abc')).map((option) => {
promisesArray.push(option.getText());
}).then(() => {
protractor.promise.all(promisesArray).then((results) => {
for(let result of results) {
console.log("Getting the drop down values = " + result);
// store the values in result and match it with given input
valuesSet.add(result);
if(result === selectedOption){
browser.executeScript('window.scrollTo(0,document.body.scrollHeight)').then(()=>{
//// This is where the error pops up
result.click();
browser.sleep(10000);
});
//result.click();
// break;
}
}
}).then(() => {
expect(valuesSet.size).not.toEqual(0,
"The returned string set from drop down list was empty!");
resolve(valuesSet);
});
}).catch((error) => {
reject(error);
});
});
}