I am am writing my XCUITests for my app, and currently struggling in finding the best solutions to dismiss my apps alerts. I have two sets of alerts, one is a notifications
alert which pops up at the beginning of a fresh install, the second is a location
alert when I navigate to the nearby tab on my app after a fresh install. I have tried using
let alert = app.alerts["\u{201c}VoucherCodes\u{201d} Would Like to Send You Notifcations"].collectionViews.buttons["OK"]
if alert.exists{
alert.tap()
}
but no success, I have also tried using a systemAlertMonitorToken
in my my setUp()
systemAlertMonitorToken = addUIInterruptionMonitorWithDescription(systemAlertHandlerDescription) { (alert) -> Bool in
if alert.buttons.matchingIdentifier("OK").count > 0 {
alert.buttons["OK"].tap()
return true
} else {
return false
}
}
Does anyone have any suggestions or point out where I am going wrong so I can fix this, thanks.