kif-framework / KIF

Keep It Functional - An iOS Functional Testing Framework
Other
6.2k stars 909 forks source link

KIF types each character twice #1254

Closed pomozoff closed 2 years ago

pomozoff commented 2 years ago

I use this method:

- (void)enterTextIntoCurrentFirstResponder:(NSString *)text

as following:

tester().enterText(intoCurrentFirstResponder: "41")

However, I see each character typed twice:

image

It looks like the next code enters a character twice:

+ (BOOL)enterCharacter:(NSString *)characterString;
{
    if ([characterString isEqualToString:@"\b"]) {
        [[UIKeyboardImpl sharedInstance] deleteFromInput];
    } else {
        [[UIKeyboardImpl sharedInstance] addInputString:characterString]; // The char is entered 1st time
    }

    [[[UIKeyboardImpl sharedInstance] taskQueue] waitUntilAllTasksAreFinished]; // The char is entered 2nd time
    CFRunLoopRunInMode(kCFRunLoopDefaultMode, keystrokeDelay, false);
    return YES;
}

Is there any workaround to fix this issue?

justinseanmartin commented 2 years ago

We don't observe this behavior in our app or the integration tests in this repo. I'd recommend setting some breakpoints where the controls are updating their text and see if they're doing something unexpected. If you can narrow down the cause or provide a repro, we could help with more guidance. Without that information, there isn't much to go on here. You should be able to see from KIF's side that we only send each character as input to UIKeyboard a single time.