I saw in this post that I could select the value from a popup menu like this:
myButton.click();
delay(1);
myButton.menus[0].menuItems.byName(value).click();
However, in my case I get the following error Error -1719: Invalid Index. It happens after the button is clicked, I can see that the menu is opened but it fails to get the menuItems.
Here is my full code
const SystemEvents = Application('System Events');
const app = SystemEvents.processes.byName(appName);
const uiElements = app
.windows[0]
.groups[0]
.groups[0]
.scrollAreas[0]
.uiElements[0]
.groups[5]
.uiElements;
const value = "One more"
for (const key in uiElements) {
if (uiElements[key].class() === 'popUpButton') {
const myButton = uiElements[key]
myButton.click();
delay(2);
myButton.menus[0].menuItems.byName(value).click();
}
}