2
override func setUp() {
    addUIInterruptionMonitor(withDescription: "App store alert") { (alert) -> Bool in
        alert.buttons.element(boundBy: 0).tap()
        return true
         }
}


func test() {
    functionThatCausesAlertToAppear()
    XCUIApplication().tap()
}

When I attempt to print a statement within the addUIInterruptionMonitor it doesn't print leading me to believe that the block isn't triggered.

Dimi
  • 193
  • 1
  • 3
  • 13

1 Answers1

2

Although this does not solve the issue at hand I've found a workaround from: 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()
}
Dimi
  • 193
  • 1
  • 3
  • 13
  • I'm having the same problem using Xcode 12.4 and an actual phone running iOS 14.5 beta as well. I used the same workaround and it works for some alerts, but doesn't work when the phone receives a full screen phone call. It does detect if the phone calls are set to banner. – TRVD1707 Feb 25 '21 at 23:29