UIAutomation 无法点击按键

UIAutomation failed to tap a key

我使用 UI 自动化和仪器进行我的 UI 测试,当我尝试点击一些字母时,仪器 return 我出错了:

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

部分代码:

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

有人对此有什么想法吗?

感谢

UIAKeyboard 对象上存在一个未记录的函数,可帮助您避免此问题。

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

您可以根据需要将延迟时间调高,但我发现 0.1 的延迟时间足以防止键盘出现故障。