XCTest app tests and permissions alerts

主宰稳场 提交于 2019-12-11 01:38:59

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!