JXA Select value from popup menu

I saw in this post that I could select the value from a popup menu like this:


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

const value = "One more"

for (const key in uiElements) {
  if (uiElements[key].class() === 'popUpButton') {
    const myButton = uiElements[key]

What is the application that you are targeting ?

it's an internal application from my work, unfortunately it's not accessible

Hard to test without seeing the application, but the first thing that comes to mind is that reference by name is case-sensitive, so I wonder whether the menu item is actually "One more" or "One More"

What menu names (if any) are returned, in your context there, by an expression like:




gives me: Error -1719: Index non valide.
I also tried with


which returns undefined

So it doesn't look as if there is, in fact, any menu collection or array associated with that myButton reference.