Created
February 16, 2016 02:03
-
-
Save matthewreagan/217a90508317fb425a8c to your computer and use it in GitHub Desktop.
Example XCTestCase Interruption Handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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