都用addUIInterruptionMonitorWithDescription
来实现
XCUIApplication *app = [[XCUIApplication alloc] init];
// 定位
[self addUIInterruptionMonitorWithDescription:@"Location Dialog" handler:^BOOL(XCUIElement * _Nonnull interruptingElement) {
XCUIElement *button = interruptingElement.buttons[@"Allow"];
if ([button exists]) {
[button tap];
return YES;
}
return NO;
}];
// 通知
[self addUIInterruptionMonitorWithDescription:@"User Notifications" handler:^BOOL(XCUIElement * _Nonnull interruptingElement) {
XCUIElement *button = interruptingElement.buttons[@"OK"];
if ([button exists]) {
[button tap];
return YES;
}
return NO;
}];
输出的中文都是unicode编码的,
\U
需要改成\u
才能用