Xcode UI 测试 UIKeyInput typeText [英] Xcode UI Test UIKeyInput typeText

查看:28
本文介绍了Xcode UI 测试 UIKeyInput typeText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Xcode UI 测试期间,我如何为符合 UIKeyInputUIView insertText ?

During Xcode UI Testing, how do I insertText for a UIView that conforms to UIKeyInput?

我创建了一个 CodeInputView 符合 UIKeyInput.

当我记录自己手动输入代码时,Xcode 写app.typeText("1234").

When I record myself manually entering a code, Xcode writes app.typeText("1234").

但是,当我尝试播放时,出现错误 UI 测试失败 - 元素和任何后代都没有键盘焦点.而且,该问题的所有解决方案都没有奏效.

But, when I try to play that back, I get the error UI Testing Failure - Neither element nor any descendant has keyboard focus. And, none of the solutions to that question has worked.

推荐答案

我找到了 UIKeyInput 的解决方案.请使用:

I've found solution for UIKeyInput. Please, use:

app.keys["1"].tap()
app.keys["2"].tap()
app.keys["3"].tap()
app.keys["4"].tap()

// Instead of app.typeText("1234")

这篇关于Xcode UI 测试 UIKeyInput typeText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆