I\'m trying to test the presence of an UIAlertView with UIAutomation but my handler never gets called.
At the beginning of my javascript i write :
UI
Make sure the UI Automation script is still running when the UIAlertView
shows.
For example, adding the following line to the end of your script will keep it running until an alert becomes accessible or the grace period for object resolution expires.
// Wait for UIAlert to appear so that UIATarget.onAlert gets called.
target.frontMostApp().alert();
I figured this out by thoroughly reading & understanding Instruments User Guide: Automating UI Testing, which I highly recommend doing as an introduction to UI Automation.
It may also be helpful to review the UIATarget Class Reference, specifically the methods popTimeout
, pushTimeout
, setTimeout
, timeout
, and delay
.