Post

Replies

Boosts

Views

Activity

XCTest - addUIInterruptionMonitor not working on iOS 17
For my test automation project I use addUIInterruptionMonitor to keep the tests running smoothly. On iOS 17 this function seems to never get triggered. This code snippet contains a test that passes on iOS 15 and 16, but not on iOS 17 (tested on iPhone 12, iOS 15.5, iPhone 13 Mini, iOS 16.4.1 and iPhone 14 Pro, iOS 17.0). To run the test, disable wifi and cell data on the test device first. import XCTest class Interruptions: XCTestCase { func testCatchInterruption() { // Run test on device with wifi and cell data disabled var caughtInterruption = false addUIInterruptionMonitor(withDescription: "Generic Alert Handler") { element -> Bool in element.buttons["OK"].tap() caughtInterruption = true return true } let safariApp = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari") safariApp.launch() // Expect to see pop-up saying "Cellular Data is turned off" safariApp.tap() sleep(5) // Pop-up should be gone XCTAssert(caughtInterruption) } }
9
3
2.1k
Sep ’23