Reporting Errors

UI Automation logs all its activity to the trace log. Up to this point Instruments has treated our log messages neutrally. We need some way to flag an error, both for the test-runner to know that something went wrong and so we can see the error when we go back over the logs.

Our acceptance test should fail if the table cell isn’t deleted. To check for this, we can tell the automation-scripting interface to wait for the cell to become invalid:

02-Behavior/step03/remove_search_term.js
 
target.pushTimeout(0.1);
 
coffeeCell.waitForInvalid();
 
target.popTimeout();

The pushTimeout and popTimeout methods on the UIATarget are our way of telling the system how long to wait when querying the interface. By default, an unsuccessful query ...

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.