UIAutomation 中的辅助功能标签

发布于 2025-01-02 09:51:06 字数 37 浏览 5 评论 0原文

使用 UIAutomation 时是否可以避免辅助功能标签?

Is it possible to avoid accessibility labels when using UIAutomation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

影子是时光的心 2025-01-09 09:51:06

如果您希望 UIAutomation 看到它,而不是 VoiceOver 等应用程序看到它,则应使用 UIAccessibilityIdentification 协议的 accessibilityIdentifier 属性。
它允许您设置稍后通过 UIAElement.name 看到的值。

通常,如果未设置,name 将从标签复制。
但当 VoiceOver 看到第二个时,第一个却看不到。

iOS 5.0 及更高版本中提供此功能。

您也可以查看 UIAccessibility 协议,它有一些更好的技巧。

If you want it to be seen by UIAutomation but not by applications like VoiceOver, you should use accessibilityIdentifier property of UIAccessibilityIdentification Protocol.
It allows you to set the value later seen trough UIAElement.name

Normally when not set, name is copied from the label.
But when the second is seen by VoiceOver the first one is not.

This is available in iOS 5.0 and later.

You can as well look at the UIAccessibility Protocol it has some more nice tricks.

老娘不死你永远是小三 2025-01-09 09:51:06

除非您的应用程序非常简单*,否则并非如此。 UIAutomation 依赖于辅助功能标签。

即使您可以做到这一点,您也不会节省任何精力,您仍然需要为 UIAutomation 提供某种方法来识别您的 UI 元素。

* 一种简单的情况是屏幕上同时只有一个不同的 UIView 子类。在这种情况下,UIAutomation 将生成对未命名元素的匿名引用,这允许您的脚本蹒跚前行。但它很脆。

Unless your app is very simple*, it is not. UIAutomation relies on accessibility labels.

Even if you could do this, you would not save any effort, you would still need to provide some way for UIAutomation to identify your UI elements.

* the simple case would be where there is only one distinct UIView subclass on screen at once. In this case, UIAutomation will generate anonymous references to the unanamed element which allow your scripts to hobble along. It is very brittle though.

回梦 2025-01-09 09:51:06

一般来说,您有两种方法来访问元素:通过其标签或通过其排名。
示例:

target.frontMostApp().mainWindow().tableViews()[0]

target.frontMostApp().mainWindow().tableViews()["Contents"]

您可以通过单击脚本编辑器中的元素来选择要在 UIAutomation 中使用的选项。

In general, you have two ways to access an element : by its label or by its rank.
Example :

target.frontMostApp().mainWindow().tableViews()[0]

or target.frontMostApp().mainWindow().tableViews()["Contents"]

You can choose which one you want to use in UIAutomation by clicking on the element in the script editor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文