我正在使用新的Xcode 7 UI测试功能编写UI测试用例.在我的应用程序的某个时刻,我请求用户允许我访问摄像头和推送通知.所以会出现两个iOS弹出窗口:"MyApp Would Like to Access the Camera"
个弹出窗口和"MyApp Would Like to Send You Notifications"
个弹出窗口.我想让我的测试取消两个弹出窗口.
UI录制为我生成了以下代码:
[app.alerts[@"cameraAccessTitle"].collectionViews.buttons[@"OK"] tap];
然而,[app.alerts[@"cameraAccessTitle"] exists]
解析为false,上面的代码生成一个错误:Assertion Failure: UI Testing Failure - Failure getting refresh snapshot Error Domain=XCTestManagerErrorDomain Code=13 "Error copying attributes -25202"
.
那么,在测试中消除一堆系统alert 的最佳方法是什么?系统弹出窗口中断了我的应用程序流程,并立即使我的正常UI测试用例失败.事实上,任何关于如何绕过系统alert 以便恢复正常流量测试的建议都是值得赞赏的.
这个问题可能与这篇同样没有答案的SO帖子有关:Xcode7 | Xcode UI Tests | How to handle location service alert?
提前谢谢.