Problems getting elements by name from UIAElementArray in UIAutomation

It's hard for me to get the interface elements by name in a UIAutomation script.

I set the accessibility bar for the text control:

accessibility panel

And I know that I have the correct parent view, since this code will work to set the contents of the field:

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 that I should do this, I get an error:

var view = UIATarget.localTarget().frontMostApp().mainWindow();
var textfields = view.textFields();
textfields['foo'].setValue("testuser");

Cannot perform an action on an invalid element: UIAElementNil from target.frontMostApp (). mainWindow (). textFields () ["foo"]

Does anyone know why the search by name function doesn't work here for me?

Thank you for understanding!

+1
3

, Device/Simulator:

- > - > - > - >

+3

, UI Automation "", " "; , . ( ) .

: , (not Label), AFAICT .

+1

UIAElementArray, :

var textfields = view.textFields();

textfields.withName("foo")[0].setValue("testuser");
0

All Articles