Xcode 7.1
Xcode 7.1 has finally fixed the issue with system warnings. There are, however, two small errors.
First, before submitting an alert, you need to configure a "UI interrupt handler." This is our way of telling the structure how to handle the alert when it appears.
Secondly, after the warning is presented, you must interact with the interface. Just listening to the application works fine, but it is necessary.
addUIInterruptionMonitorWithDescription("Location Dialog") { (alert) -> Bool in alert.buttons["Allow"].tap() return true } app.buttons["Request Location"].tap() app.tap()
The Location dialog box is just a line that helps the developer determine which handler was accessed and is not a warning type.
I believe that returning true from the handler means it is “completed”, which means that it will not be called again. For your situation, I would try to return false so that the second warning calls the handler again.
Xcode 7.0
The following will reject one “system warning” in Xcode 7 Beta 6:
let app = XCUIApplication() app.launch() // trigger location permission dialog app.alerts.element.collectionViews.buttons["Allow"].tap()
Beta 6 introduced many fixes for testing the user interface, and I believe that this was one of them.
Also note that I call -element directly on -alerts . Calling -element on an XCUIElementQuery forces the framework to select the same matching element on the screen. This is great for alerts where you can only see one visible at a time. However, if you try this for a label and have two labels, the framework will throw an exception.
Joe Masilotti Aug 26 '15 at 13:29 2015-08-26 13:29
source share