Hello all guys!
Sorry, maybe issues has already been resolved or I mean questions on this topic have been considered and already there is somewhere an answer.
But!
I'm starting working as Automation Test Enginner with Swift for iOS applications. On my local machine I have Xcode version 9.1 (9B55) and I'm trying testing application on different version iOS. Currently I'm writing tests for iOS version 10.3.3
I facing with issue about handler system alert, for example alert about location.
When user tap into application on some button the system show alert "Allow “My Application Name” to access your location while you use the app?".
I tried diferent variants:
1) - simple variant after recording
let app = XCUIApplication()
app.alerts["Allow “My Application Name” to access your location while you use the app?"].buttons["Allow"].tap()
But after launch I have error:
UI Test Activity:
Assertion Failure: <unknown>:0: No matches found for Find: Descendants matching type Alert from input {(
Application, 0x17019db50, pid: 522, label: 'My Application Name'
)}
2) -simple variant with addUIInterruptionMonitor
let allowButtonPredicate = NSPredicate(format: "label == 'Always Allow' || label == 'Allow'")
_ = addUIInterruptionMonitor(withDescription: "Allow “My Application Name” to access your location while you use the app?") { (alert) -> Bool in
let alwaysAllowButton = alert.buttons.matching(allowButtonPredicate).element.firstMatch
if alwaysAllowButton.exists {
alwaysAllowButton.tap()
return true
}
return false
}
But after launch I see that code does not enter this area 😟
Could someone please help me with how can I handler system alerts?
Thanks