iOS UITest:如何测试自定义辅助功能? [英] iOS UITest: How to test custom accessibility actions?

查看:259
本文介绍了iOS UITest:如何测试自定义辅助功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想支持VoiceOver。我在 UITableViewCell 里面有一个 UIButton 。根据最佳实践,我禁用了可访问性按钮( .isAccessibilityElement = false ),并为该单元实现了自定义可访问性操作( accessibilityCustomActions,NSAccessibilityCustomAction )。

I want to support VoiceOver. I have an UIButton inside of an UITableViewCell. According to a best practice I have disabled the button for accessibility (.isAccessibilityElement = false) and implemented a custom accessibility action for the cell (accessibilityCustomActions, NSAccessibilityCustomAction).

通过这种方式,VoiceOver不会找到并读取按钮作为自己的元素。为了使按钮后面的功能可访问,我向该单元格添加了一个自定义可访问性操作。使用自定义动作,用户可以上下滑动来选择动作。然后双击来执行它。

This way VoiceOver would not find and read the button as an own element. To make the feature behind the button accessible, I have added a custom accessibility action to the cell. With the custom action the user can select the action with swipe up and down. And then perform it with double-tap.

现在,我想使用UITest测试此操作。无法访问UITest内部的按钮,因为它的可访问性已被禁用。

Now I want to test this action with an UITest. It's not possible to access the button inside of an UITest, because its disabled for accessibility.

如何在UITest内部执行自定义可访问性操作?

How can I perform a custom accessibility action inside of an UITest?

推荐答案


如何在UITest中执行自定义可访问性操作?

How can I perform a custom accessibility action inside of an UITest?

实际上,您不能使用{Xcode 11,iOS 13},即使您可以在UITest中获得一系列动作,它也为零并且您无法从XCUITEST 中触发选择器(UI测试无法像单元测试那样获得对应用程序的代码级访问)

Actually, you can't with {Xcode 11, iOS 13} and even if you can get an array of actions in UITest, it's nil and you can't fire the selectors from XCUITEST (UI tests don't get code-level access to the app as unit tests do).

手动测试是当前使用VoiceOver测试辅助功能自定义操作的唯一方法。

Testing manually is currently the only way to test accessibility custom actions with VoiceOver.

看看这个答案由苹果工程师在WWDC 2019期间给出。

Take a look at this answer given by an Apple engineer during the WWDC 2019.

这篇关于iOS UITest:如何测试自定义辅助功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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