August 2013
Intermediate to advanced
200 pages
5h 26m
English
Now that we have the predicate basics down, let’s take a moment to imagine some use cases that may not be obvious but are quite powerful. Searching for elements by name anywhere on the screen could give us false positives. Let’s narrow our search by building a predicate to find the first element that matches a given name and type:
| 06-Universal/step23/automation/sandbox.js | |
| | var predicate = predicateWithFormat("name = %@ and class.description = %@", |
| | "coffee", |
| | "UIATableCell"); |
| | var cell = Screen.searchWithPredicate(predicate); |
| | assert(cell, "Couldn't find cell"); |
| | cell.tap(); |
This works because of the way predicates interact with key-value coding in Objective-C. The elements that we talk to in ...
Read now
Unlock full access