So recently Apple introduced this prompt: “XXXX” Wants to Use “auth0.com” to Sign In Where “XXXX” is the ios app name.
This alert/dialog comes up when in the case of Auth0 the user clicks on “Login with Google” or “Login with Facebook”. That’s all nice but when running IOS UI tests, this dialog doesn’t go away when using the usual way of dismissing system dialogs:
func doUserLogin(_ app: XCUIApplication) {
app.staticTexts["notLoggedInActivelabel"].tap()
// this will bring up oauth0 login window in ios
// setup a handler to dismiss the system alert
let handler = self.addUIInterruptionMonitor (withDescription: "allow oauth") { (alert) -> Bool in
// code should come here where the dialog is presented,
// but it never does ....
alert.buttons["Continue"].tap() // click Continue Button
return true
}
// click the login with GOOGLE button. This brings up dialog “XXXX” Wants to Use “auth0.com” to Login
app.scrollViews.otherElements.buttons["LOG IN WITH GOOGLE"].tap()
// this step is required when using addUIInterruptionMonitor
app.tap()
removeUIInterruptionMonitor(handler)
}
It kinda makes sense to me: This is a security system dialog introduced by Apple in order to improve security. Having it easily dismissed in the code would defeat the purpose.
But still, anyone knows if it's possible to dismiss this dialog in an XCTestCase?
I think Apple expects from a developer to make use of the introduced addUIInterruptionMonitor.
In fact, the
addUIInterruptionMonitor(withDescription: )
is not working, so I went down the road to access the Springboard and select the appropriate permission on the system alert.1. Extended the XCTestCase to reuse this function, if necessary
2. Call this function in your test like
Optional: Springboard Class
I also created a Springboard Class, as I have also System Settings tests etc. running...
This way, you could call your
XCUITestCase
extension the following way:If, the
addUIInterruptionMonitor(withDescription: )
was actually working, this could then look like the following:Caution: currently, only working for Authorization/Permission alerts of Location, Microphone, etc.