【问题标题】:UIAutomation failed to tap a keyUIAutomation 未能点击一个键
【发布时间】:2015-08-24 07:45:10
【问题描述】:

我使用 UIAutomation 和仪器进行 UI 测试,当我尝试点击一些字母时,仪器返回错误:

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

部分代码:

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

有人对此有什么想法吗?

谢谢

【问题讨论】:

  • 在点击密码字段和输入字符串之间添加延迟有帮助吗?显示键盘的动画大约需要 0.33 秒才能完成。

标签: ios testing automated-tests instruments ios-ui-automation


【解决方案1】:

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

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

您可以将延迟提高到任意高,但我发现延迟 0.1 足以防止键盘出现故障。

【讨论】:

    猜你喜欢
    • 2012-02-03
    • 1970-01-01
    • 2022-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-17
    • 1970-01-01
    相关资源
    最近更新 更多