Identifying Elements with Accessibility APIs

Our test works fine for the moment, but we have a fragile situation on our hands. As we see in Figure 26, Finding the map pins in the window, the pin annotation views are represented as just plain UIAElement instances. Although we’re able to use the special filtering methods such as buttons and cells to fetch only elements of a certain type, we don’t have that convenience here. We have to use the generic elements method.

This could be a problem if we were testing for a pin with the name Legal, for instance, because the static text element for the Map Kit legal disclaimer has that name and is a sibling in the element array, along with all our pins. This could give us a false positive in a test. ...

Get Test iOS Apps with UI Automation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.