3

I have the issue that I could not close the notification, location, photo access permission alert in iOS10 simulator, Xcode 9, UITests, but it works well in iOS11 simulator.

I found the thread that discuss about the similar issue, but there is not any useful workaround to fix it.

https://forums.developer.apple.com/thread/86989

Cœur
  • 37,241
  • 25
  • 195
  • 267
Alex Cheng
  • 829
  • 8
  • 20

1 Answers1

0

Did you try

app.tap()

in the place you expect the dialog?

Or this method : https://useyourloaf.com/blog/handling-system-alerts-in-ui-tests/

This worked for me in setup method after app.launch()

     addUIInterruptionMonitor(withDescription: "System Dialog") { (alert) -> Bool in
        let savePasswordButton = alert.buttons["Save Password"]
        if savePasswordButton.waitForExistence(timeout: 3) {
            savePasswordButton.tap()
            return true
        }
        let allowButton = alert.buttons["Allow"]
        if allowButton.waitForExistence(timeout: 3) {
            allowButton.tap()
            return true
        }
        self.app.tap()
        return false
    }
ergunkocak
  • 3,334
  • 1
  • 32
  • 31