ios-ui-automation – target.frontMostApp().键盘()无法找到键’N’

我正在尝试使用UI Automation自动键盘输入.

target.frontMostApp().keyboard().typeString("INTERCOM")

但是在输入“I”后我会收到此错误

target.frontMostApp().keyboard() failed to locate key 'N'
Script threw an uncaught JavaScript error: target.frontMostApp().keyboard() failed to locate key 'N'

我有一个本地化的瑞典键盘.

任何人都知道这是一个我错过的错误吗?

最佳答案 这可能有所帮助:

var vKeyboard = target.frontMostApp().keyboard();
vKeyboard.setInterKeyDelay(0.1);
vKeyboard.typeString("INTERCOM");

默认情况下,此延迟设置为0.03秒.这不足以让您的应用程序更新键盘上的按键.在确定typeString键盘方法的键之间增加此超时将对您有所帮助. UIAKeyboard参考页面上没有setInterKeyDelay的描述,但此方法可用于UIAKeyboard.
我也不确定其他语言.我不知道typeString是否允许在其他语言上键入,但这100%适用于iOS 5.x的英文键盘.

点赞