Permalink
Browse files

Added stepToEnterTextIntoCurrentFirstResponder

  • Loading branch information...
1 parent 1b59166 commit 3cfd99ed71972bf64f6d7e7e9c127165a8ae1dbf @jpsim jpsim committed Nov 15, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 Classes/KIFTestStep.m
View
@@ -350,6 +350,23 @@ + (id)stepToTapScreenAtPoint:(CGPoint)screenPoint;
}];
}
++ (id)stepToEnterTextIntoCurrentFirstResponder:(NSString *)text {
+ NSString *description = [NSString stringWithFormat:@"Type the text \"%@\" into the current first responder", text];
+ return [self stepWithDescription:description executionBlock:^(KIFTestStep *step, NSError **error) {
+ // Wait for the keyboard
+ CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.5, false);
+
+ for (NSUInteger characterIndex = 0; characterIndex < [text length]; characterIndex++) {
+ NSString *characterString = [text substringWithRange:NSMakeRange(characterIndex, 1)];
+
+ if (![self _enterCharacter:characterString]) {
+ KIFTestCondition(NO, error, @"Failed to find key for character \"%@\"", characterString);
+ }
+ }
+ return KIFTestStepResultSuccess;
+ }];
+}
+
+ (id)stepToEnterText:(NSString *)text intoViewWithAccessibilityLabel:(NSString *)label;
{
return [self stepToEnterText:text intoViewWithAccessibilityLabel:label traits:UIAccessibilityTraitNone expectedResult:nil];

0 comments on commit 3cfd99e

Please sign in to comment.