Skip to content

Commit f23591f

Browse files
committed
Merge pull request #234 from percysnoodle/enter-text-fix
Wait for text to be updated
2 parents 79db32c + 002e41b commit f23591f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Classes/KIFTestStep.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,14 @@ + (id)stepToEnterText:(NSString *)text intoViewWithAccessibilityLabel:(NSString
482482
// We trim \n and \r because they trigger the return key, so they won't show up in the final product on single-line inputs
483483
NSString *expected = [expectedResult ? expectedResult : text stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
484484
NSString *actual = [[view performSelector:@selector(text)] stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
485+
486+
if ([actual isEqualToString:expected]) {
487+
return KIFTestStepResultSuccess;
488+
}
489+
490+
// On iOS 7, the text property isn't always immediately updated, so wait for that to happen and fetch the values again
491+
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, false);
492+
actual = [[view performSelector:@selector(text)] stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
485493
KIFTestCondition([actual isEqualToString:expected], error, @"Failed to get text \"%@\" in field; instead, it was \"%@\"", expected, actual);
486494
}
487495

0 commit comments

Comments
 (0)