Skip to content

Instantly share code, notes, and snippets.

@matthewreagan
Created February 16, 2016 02:03
Show Gist options
  • Save matthewreagan/217a90508317fb425a8c to your computer and use it in GitHub Desktop.
Save matthewreagan/217a90508317fb425a8c to your computer and use it in GitHub Desktop.
Example XCTestCase Interruption Handler
id systemAlertMonitor = [self addUIInterruptionMonitorWithDescription:@"Alert Handler" handler:^BOOL(XCUIElement * _Nonnull interruptingElement) {
//Exampe: Check for expected UI indicating a particular system alert
if (interruptingElement.staticTexts[@"<Alert text example>"].exists &&
interruptingElement.buttons[@"OK"].exists)
{
//Dismiss the alert (e.g., by calling -click on the target button of interruptingElement)
[interruptingElement.buttons[@"OK"] click];
//Return YES if you handled the alert
return YES;
}
//... or NO otherwise
return NO;
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment