UITesting of Alerts in xCode 7.1

后端 未结 2 2120
孤街浪徒
孤街浪徒 2021-02-09 05:04

I\'m writing UITests in xCode 7.1 and have a problem in testing alerts (Allow notifications in my case). While creating a test xCode writes this code:

app.alerts         


        
2条回答
  •  盖世英雄少女心
    2021-02-09 05:58

    Here is an example how to do it with an app requesting local notification permission access:

    addUIInterruptionMonitorWithDescription("Local Dialog") { (alert) -> Bool in
         if alert.collectionViews.buttons["OK"].exists {
              alert.collectionViews.buttons["OK"].tap()
              return true
         }
         return false
    }
    

提交回复
热议问题