diff --git a/Classes/KIFUITestActor.m b/Classes/KIFUITestActor.m index 852e6797d..a38169d3b 100644 --- a/Classes/KIFUITestActor.m +++ b/Classes/KIFUITestActor.m @@ -212,12 +212,17 @@ - (void)tapAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView } else { [view tapAtPoint:tappablePointInElement]; } - - KIFTestCondition(![view canBecomeFirstResponder] || [view isDescendantOfFirstResponder], error, @"Failed to make the view into the first responder: %@", view); return KIFTestStepResultSuccess; }]; + // Controls might not synchronously become first-responders. Sometimes custom controls + // may need to spin the runloop before reporting as the first responder. + [self runBlock:^KIFTestStepResult(NSError *__autoreleasing *error) { + KIFTestWaitCondition(![view canBecomeFirstResponder] || [view isDescendantOfFirstResponder], error, @"Failed to make the view into the first responder: %@", view); + return KIFTestStepResultSuccess; + } timeout:0.5]; + [self waitForAnimationsToFinish]; }