2016-03-24 6 views

答えて

2

あなたは、一般的に来るからダイアログを防ぐために、通知および他のデータ要求をからかっする必要があります。手動で通知を受け入れ、テストを再実行することもできます。私たちは、このためにプライベート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 
+0

しかし、UIAutomationは非壊れたデバイスでは動作しないようです。設定 - >デベロッパー - > UIオートメーションを有効にする設定がありますが、アプリがクラッシュし、「このデバイスでUIAutomationが有効になっていません.UIAutomationを設定で有効にする必要があります。 – Paul

+0

それは変です。私はiPhone 6sで試してみましたが、うまく機能しました。デバイスを再起動して、UIAutomationが設定で有効になっていることを確認して、テストを再度実行してみてください。 – khandpur

関連する問題