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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access