如何确认系统警报,如允许通知
How to confirm system alert like allow notification
如果是第一次安装,需要允许通知,如何确认?有人遇到了吗?
您通常应该模拟通知和其他数据请求,以防止出现对话框。您也可以手动接受通知并重新 运行 您的测试。为此,我们尝试使用私有 UIAutomation 框架,发现我们可以用它来实现。例如,按下左警报按钮。
@interface SystemAlert : NSObject
- (void)tapLeftButton;
@end
@interface SystemAlert (ForMethodCompletionOnly)
+ (id)localTarget;
- (id)frontMostApp;
- (id)alert;
- (id)buttons;
@end
@implementation SystemAlert
+ (void)load {
dlopen([@"/Developer/Library/PrivateFrameworks/UIAutomation.framework/UIAutomation" fileSystemRepresentation], RTLD_LOCAL);
}
- (void)tapLeftButton {
id localTarget = [NSClassFromString(@"UIATarget") localTarget];
id app = [localTarget frontMostApp];
id alert = [app alert];
id button = [[alert buttons] objectAtIndex:0];
[button tap];
}
@end
如果是第一次安装,需要允许通知,如何确认?有人遇到了吗?
您通常应该模拟通知和其他数据请求,以防止出现对话框。您也可以手动接受通知并重新 运行 您的测试。为此,我们尝试使用私有 UIAutomation 框架,发现我们可以用它来实现。例如,按下左警报按钮。
@interface SystemAlert : NSObject
- (void)tapLeftButton;
@end
@interface SystemAlert (ForMethodCompletionOnly)
+ (id)localTarget;
- (id)frontMostApp;
- (id)alert;
- (id)buttons;
@end
@implementation SystemAlert
+ (void)load {
dlopen([@"/Developer/Library/PrivateFrameworks/UIAutomation.framework/UIAutomation" fileSystemRepresentation], RTLD_LOCAL);
}
- (void)tapLeftButton {
id localTarget = [NSClassFromString(@"UIATarget") localTarget];
id app = [localTarget frontMostApp];
id alert = [app alert];
id button = [[alert buttons] objectAtIndex:0];
[button tap];
}
@end