XCTest / Xcode 9 beta 5: Unable to tap "Allow" on System Alert

Number:rdar://33842609 Date Originated:08/10/2017
Status:Open Resolved:No
Product:Xcode Product Version:9.0 beta 5
Classification:Error Reproducible:Always
I am using XCode 9 beta 5 to setup a XCTest. For my app, the app pops up a system alert for Notifications when the app is opened first time after installation.
Before Xcode 9, if i tried to tap button on the screen present, XCTest would tap 'Don't Allow' button by default and proceed.

Now, I am trying to tap 'Allow' using this code:

XCUIApplication().alerts["“AppName” Would Like to Send You Notifications"].buttons["Allow"].tap()

The above line was generated by UI Recorder and does not work in the test. It fails with this error:
Assertion Failure: xyz.swift:38: No matches found for Find: Descendants matching type Alert from input {(
    Application, 0x174186f50, pid: 3772, label: 'AppName'

I have referred this StackOverflow answer until now, and the UIInterruption Monitor did not work in Xcode 9, or I could not get it working fully.

Read this:

but could not write a functioning handler in Swift.

What I tried until now:
        addUIInterruptionMonitor(withDescription: "Notifications Dialog") { (alert) -> Bool in
                return true


Any help is appreciated, even if I can dismiss the notifications alert by tapping "Don't Allow" instead of "Allow"

Steps to Reproduce:
1. Install an app that requires Push Notification permissions
2. Write an XCTest which tries to tap "Allow" on the Notifications system alert view
3. Record tapping "Allow" using UIRecorder
4. Run the above test in Xcode

Expected Results:
System Alert for Notifications is dismissed by tapping 'Allow' and rest of the test continues.

Observed Results:
Test fails with error similar to:
No matches found for Find: Descendants matching type Alert from input {(
    Application, 0x174186f50, pid: 3772, label: 'AppName'

XCode Version 9.0 beta 5 (9M202q)
macOS 10.12.6 (16G29)


This was fixed with Xcode 9.0 release build

By nagarkarchetan at Sept. 20, 2017, 11:53 p.m. (reply...)

I use the version with addUIInterruptionMonitor which worked fine on Xcode8, but no longer works on 9. Also, my permissions are not allowed by default since Xcode 9. You only have the notifications permission?

By ioanaioana70 at Oct. 5, 2017, 12:49 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!