如何解决XCUItest addUIInterruptionMonitor无法在iOS14模拟器和Xcode 12上捕获警报
override func setUp() {
addUIInterruptionMonitor(withDescription: "App store alert") { (alert) -> Bool in
alert.buttons.element(boundBy: 0).tap()
return true
}
}
func test() {
functionThatCausesAlertToAppear()
XCUIApplication().tap()
}
当我尝试在addUIInterruptionMonitor中打印一条语句时,它不会打印,这使我认为该块未触发。
解决方法
尽管这不能解决当前的问题,但我发现了一种解决方法:addUIInterruptionMonitor(withDescription:handler:) not working on iOS 10 or 9
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let allowBtn = springboard.buttons["Allow"]
if allowBtn.waitForExistence(timeout: 10) {
allowBtn.tap()
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。