Ich habe ein Problem, wenn ich versuche, Seriensystemalarm zu ermöglichen, arbeite nur einmal, und nächste Warnung nicht "Erlauben" Ich google mehr Zeit, und wissen über diesen Beitrag: (Xcode 7 UI Testing: how to dismiss a series of system alerts in code) Nichts .. nicht funktionieren. Hier mein aktueller Code, erster Alarm "erlaubt" erfolgreich, nächster Alarm nicht erkannt ..Xcode UI Testing erlauben Systemwarnungen Serie
XCUIApplication *app = [[XCUIApplication alloc] init];
app.launchEnvironment = @{
@"isUITest" : @YES,
@"withFakeData" : fakeData
};
[app launch];
for (int i = 1; i <= self.possibleSystemAlerts; 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];
}
Mit freundlichen Grüßen, Ivan.
UPD:
Okay, fand ich Lösung, wie nach dem ersten Alarm, versuchen Sie an zweiter Stelle (Danke für diese Website: 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) Nur immer brauchen Rückkehr NO.
Aber ein anderes Problem ...
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'
)}
Er versucht schließen dritte Benachrichtigung, nicht zweitens natürlich er dieses System Alarm wird nicht gefunden ...
Ist die Seite, mit der du im Update verlinkt hast, nicht nur ein Scraping desselben Q/A, mit dem du in deinem ursprünglichen Post verlinkt hast? –