I need to run continuous integration on xcode server using a lot of simulators. Is there a way to force it to always accept permission alerts like:
Allow "App" to access your photos
and so on...
I need to run continuous integration on xcode server using a lot of simulators. Is there a way to force it to always accept permission alerts like:
Allow "App" to access your photos
and so on...
In your setUp()
method, create an interruption monitor and handle the alert by tapping the OK button. This means that whenever you try to interact with the app, a check will be made to see if the permissions view is in the way, and tap the OK button.
let permissionInterruptionMonitor = addUIInterruptionMonitor(withDescription: "Photos permission alert") { (alert) in
alert.buttons["OK"].tap()
return true // The interruption has been handled
}
If there are other alerts that may appear in your app with an OK button, but you don't want those to be automatically handled, you should make sure that the interruption monitor handler checks that it is the alert that you want to handle.
let permissionInterruptionMonitor = addUIInterruptionMonitor(withDescription: "Photos permission alert") { (alert) in
if alert.staticTexts["\"AppName\" Would Like To Access Your Photos"].exists {
alert.buttons["OK"].tap()
return true // The interruption has been handled
}
return false // The interruption has not been handled
}