I noticed some weird behavior in a UIAutomation script I had written a while back that I hadn't ran in a while. My assertions were failing; after doing some digging, I saw that when iterating a UIAElement's .elements()
, subelements do not appear to be equal to themselves.
This has worked for me as expected in the past, but appears to be broken in at least XCode 4.3.2
To repro:
- create a single-view app
- throw some elements in the view, set Accessibility Labels on the elements so they get picked up by UIAutomation
Run the following script in UIAutomation:
var elements = UIATarget.localTarget().frontMostApp().mainWindow().elements(); for (var i = 0; i < elements.length; i++) { var el1 = elements[i]; var el2 = elements[i]; var equals = (el1 == el2); UIALogger.logMessage(el1.label() + " is equal to " + el2.label() + " ? " + equals); }
- See that
el1
andel2
do not appear to reference the same object.
I'm not sure if this is the expected behavior, though this seems very off to me. If anybody has any insight, I'd appreciate it.