I'm having trouble getting interface elements by name in a UIAutomation script.
I have set up the accessibility panel for a text control:
And I know that I have the right parent view, as this code will work to set the field contents:
var view = UIATarget.localTarget().frontMostApp().mainWindow();
var textfields = view.textFields();
textfields[0].setValue("testuser");
Unfortunately, if I try to access the field by name, as the docs seem to indicate I should be able to do, I get an error:
var view = UIATarget.localTarget().frontMostApp().mainWindow();
var textfields = view.textFields();
textfields['foo'].setValue("testuser");
Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().mainWindow().textFields()["foo"]
Does anybody have any idea why the find-by-name functionality doesn't seem to be working here for me?
Thanks for any insight!