问题
I'm writing XCTest app tests that test some UIViewControllers
by calling presentViewController
on the UIApplication
rootViewController
.
This works fine, except for permissions dialogs. Some of the UIViewControllers
make the system pop permissions dialogs for things like camera or microphone access. I'm not sure how to dismiss them.
If this were a UI test, I could use addUIInterruptionMonitorWithDescription
and tap
the alert away.
However, I'm not sure how to make this work. Can an app test access UI test features?
回答1:
In xcode ui test, to access system pop permissions dialogs, use the below code:
self.addUIInterruptionMonitorWithDescription("your alert text", handler: { (alert) -> Bool in
yourAlertElement.tap()
return true
})
Hope this will help and if you have any confusion, let me know.
来源:https://stackoverflow.com/questions/40666197/xctest-app-tests-and-permissions-alerts