From 60183c05b7f3007edb4a8a9c8b1233567e02131f Mon Sep 17 00:00:00 2001 From: Justin Martin Date: Thu, 21 Jan 2016 14:41:43 -0800 Subject: [PATCH] Setting first responder on an accessibility element may be delayed --- Classes/KIFUITestActor.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Classes/KIFUITestActor.m b/Classes/KIFUITestActor.m index 5b2c9683f..2fc57600a 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]; }