所以最近苹果推出了这个提示:“XXXX” Wants to Use “auth0.com” to Sign In 其中“XXXX”是ios应用名称。
在 Auth0 的情况下,当用户单击“使用 Google 登录”或“使用 Facebook 登录”时,会出现此警报/对话框。这一切都很好,但是在运行 IOS UI 测试时,当使用通常的方式关闭系统对话框时,此对话框不会消失:
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)
}
这对我来说有点道理:这是 Apple 为提高安全性而引入的安全系统对话框。让它在代码中很容易被忽略会破坏目的。
但是,任何人都知道是否可以在 XCTestCase 中关闭此对话框?