Post

Replies

Boosts

Views

Activity

Reply to XCUITest interact with system dialogs
As of iOS 13 you don't necessarily need an interruption monitor. If you know the alert is present (to be honest this should nearly always be the case since you should know exactly when the alert is triggered during your test run) you can simply locate the alert using the springboard app. Take a look at this example that returns the buttons for the camera as well as location permission alerts: import XCTest enum PermissionElements { private static let springboardApp = XCUIApplication(bundleIdentifier: "com.apple.springboard") static func allowLocationButton() -> XCUIElement { return springboardApp.alerts.buttons["Allow While Using App"] } static func allowCameraButton() -> XCUIElement { return springboardApp.alerts.buttons["OK"] } } This includes some extra layers of abstraction to conform to SOLID programming principles, but the idea is the same: you don't need to sort through alerts if you know there is only a single alert on screen, and you should know that if you are in control of the AUT's state.
May ’22