Skip to content

Instantly share code, notes, and snippets.

@bnickel
Created September 16, 2013 03:40
Show Gist options
  • Save bnickel/6576490 to your computer and use it in GitHub Desktop.
Save bnickel/6576490 to your computer and use it in GitHub Desktop.
A step to tap wildly on different buttons while trying to get your app to a final state. For example, if your home screen has a "Login" button, your logout flow consists of tapping "Logout" and "Confirm", and your tests could fail leaving alerts with "OK" or "Continue", you could use `[tester tapViewsWithAccessibilityLabels:@[@"OK", @"Continue",…
@implementation KIFUITestActor (BruteForceEscape)
- (void)tapViewsWithAccessibilityLabels:(NSArray *)labels whileWaitingForViewWithAccessibilityLabel:(NSString *)targetLabel
{
[self runBlock:^KIFTestStepResult(NSError **error) {
for (NSString *label in labels) {
UIView *view;
UIAccessibilityElement *element;
if ([UIAccessibilityElement accessibilityElement:&element view:&view withLabel:label value:nil traits:UIAccessibilityTraitNone tappable:YES error:NULL]) {
[self tapAccessibilityElement:element inView:view];
}
}
return [UIAccessibilityElement accessibilityElement:NULL view:NULL withLabel:targetLabel value:nil traits:UIAccessibilityTraitNone tappable:NO error:error] ? KIFTestStepResultSuccess : KIFTestStepResultWait;
}];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment