Search code examples
iostestingautomated-testsinstrumentsios-ui-automation

UIAutomation failed to tap a key


i use UIAutomation and instrument for my UI Tests and when i try to tap some letters, instrument return me an error:

Script threw an uncaught JavaScript error: target.frontMostApp().keyboard() failed to tap 'V' on line 27

A part of code:

passwordField.tap();
target.frontMostApp().keyboard().typeString("VEMO");

Has anyone some ideas about it?

Thank


Solution

  • There is an undocumented function that exists on the UIAKeyboard object that will help you avoid this problem.

    var keyboard = target.frontMostApp().keyboard();
    keyboard.setInterKeyDelay(seconds);
    keyboard.typeString("VEMO");
    

    You can push the delay up as high as you want but I found that a delay of 0.1 was enough to prevent the keyboard from failing.