The cancel button on an alert is always tapped to keep the application from blocking unless the onAlert
callback returns true
. By returning true
, you are telling the alert handling mechanism that you will handle tapping the appropriate button to dismiss the alert.
Change your alert callback to look like this:
UIATarget.onAlert = function onAlert(alert) {
UIALogger.logMessage("alert Shown");
UIALogger.logMessage(frontApp.alert().name());
UIALogger.logMessage(frontApp.alert().staticTexts()[1].value());
return true; // <-- Adding this line
}
Conversely, returning false
or leaving out a return value altogether signals to the alert handling mechanism that the cancel button should be tapped.