XCTest:如何正确设置 UITextView 的辅助功能特性? [英] XCTest: How to correctly setup Accessibility Traits for UITextView?

查看:34
本文介绍了XCTest:如何正确设置 UITextView 的辅助功能特性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正确设置了辅助功能标识符的 UITextView.当我尝试使用app.textViews["textViewIdentifier"] 钩住这个元素时,它不起作用.

I have a UITextView with Accessibility Identifier properly set up. When I try to hook this element usingapp.textViews["textViewIdentifier"] it does not work.

它可能不起作用,因为我没有正确设置可访问性特征.我在界面构建器或 documentation

It probably does not work because I'm not setting up accessibility traits correctly. I don't see any traits available for UITextView in interface builder or documentation

使用不同的特征我能够找到 textview 但它不执行 textView.typeText("test text") 因为特征与类型不匹配.

Playing with different traits I was able to find the textview but it does not execute textView.typeText("test text") since traits don't match with type.

TextView 只包含在默认的 UIView 中.

TextView is contained only in default UIView.

经过更多测试,问题的核心似乎是为 UITextView 正确设置辅助功能特性.您如何正确设置 UITextView 的 Accessibility Traits?

After more testing, the core of issue seems to setting up Accessibility traits correctly for UITextView. How do you correctly setup Accessibility Traits for UITextView?

推荐答案

就我对你的帖子的理解,这里有两个问题:

As far as I understand your post, there are two questions here:

  • 如何设置辅助功能标识符
  • 如何在 UI 测试期间在文本视图中键入文本

我可以回答第二个问题.您可以在断点中使用 po app.textViews 来查看标识符,或者,如果 textview 是页面上唯一的一个,则使用 app.textViews.firstMatch.

I can answer the second question. You can either use po app.textViews in a breakpoint to see the identifier, or, if the textview is the only one on the page, use app.textViews.firstMatch.

如果您需要第一个问题的答案,我会将其留给其他人.

If you need an answer to the first question I will leave that to someone else.

这篇关于XCTest:如何正确设置 UITextView 的辅助功能特性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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