O'Reilly logo

Test iOS Apps with UI Automation by Jonathan Penn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Searching the Element Tree with Predicates

Up to this point, we’ve been giving our screen objects the intelligence to find the elements they need to get the job done. In many cases this is a great way to keep steps organized, and I recommend it. But sometimes we just want to do a quick search of the whole screen. If, say, we know there’s only one button named Edit, then we don’t care which toolbar it lives in.

UI Automation doesn’t provide a mechanism to do this for us, but we can build our own tool using the knowledge we’ve gained up to this point. Rather than just look up elements by name, we’re going to learn about using predicate expressions that let us execute arbitrary queries. Then we’ll build a breadth-first recursive search in a series ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required