大佬教程收集整理的这篇文章主要介绍了ios – Xcode UI测试允许系统警报系列,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
XCUIApplication *app = [[XCUIApplication alloc] init]; app.launchEnvironment = @{ @"isUITest" : @YES,@"withFakeData" : fakeData }; [app launch]; for (int i = 1; i <= self.possibleSy@L_944_6@Alerts; i++) { NSLog(@"%d",i); XCTestExpectation *expectation = [self expectationWithDescription:@"High Expectations"]; id monitor = [self addUIInterruptionMonitorWithDescription:@"Push notifications" handler:^BOOL(XCUIElement *_Nonnull interrupTingElement) { XCUIElement *element = interrupTingElement; XCUIElement *allow = element.buttons[@"Allow"]; XCUIElement *ok = element.buttons[@"OK"]; if ([ok exists]) { [ok tap]; [expectation fulfill]; return YES; } if ([allow exists]) { [allow forCETap]; [expectation fulfill]; return YES; } return NO; }]; [app tap]; [self waitForExpectationsWithTimeout:6.0 handler:^(NSError *error) { if (error) { NSLog(@"Timeout Error: %@",error); } }]; [self removeUIInterruptionMonitor:monitor]; }
最好的祝福,
伊万.
UPD:
好的,我找到了解决方案,如何在第一次提醒后,尝试关闭第二个(感谢这个网站:http://www.it1me.com/it-answers?id=32148965&s=Template:Viper&ttl=Xcode+7+UI+Testing%3A+how+to+dismiss+a+series+of+system+alerts+in+code)只需要返回总是没有.
但另一个问题……
t = 10.18s Find: Descendants matching type Alert t = 10.18s Find: Identity Binding t = 11.19s Find the "Allow “MyApp” to access your LOCATIOn while you use the app?" Alert (retry 1) t = 11.19s Snapshot accessibility hierarchy for com.apple.springboard t = 11.26s Find: Descendants matching type Alert t = 11.26s Find: Identity Binding t = 12.27s Find the "Allow “MyApp” to access your LOCATIOn while you use the app?" Alert (retry 2) t = 12.27s Snapshot accessibility hierarchy for com.apple.springboard t = 12.33s Find: Descendants matching type Alert t = 12.34s Find: Identity Binding t = 12.42s Assertion Failure: UI TesTing Failure - No matches found for "Allow “MyApp” to access your LOCATIOn while you use the app?" Alert Query input was {( Alert 0x7febe8731630: Traits: 72057602627862528,{{25.0,193.0},{270.0,182.0}},label: '“MyApp” Would Like to Send You Notifications' )}
addUIInterruptionMonitor(withDescription:"First Dialog") { (alert) -> Bool in alert.buttons["Allow"].tap() return true } addUIInterruptionMonitor(withDescription:"Second Dialog") { (alert) -> Bool in alert.buttons["Allow"].tap() return true } addUIInterruptionMonitor(withDescription:"Third Dialog") { (alert) -> Bool in alert.buttons["Allow"].tap() return true } let app = XCUIApplication() app.launch() app.tap() app.tap() app.tap()
这三个水龙头将连续启动每个警报处理程序,而不会实际触发您的应用程序中的任何事件.另请注意,每个中断处理程序都不会指定有关警报的任何内容,只会指定确认按钮.
以上是大佬教程为你收集整理的ios – Xcode UI测试允许系统警报系列全部内容,希望文章能够帮你解决ios – Xcode UI测试允许系统警报系列所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。