UITest: How to test custom accessibility actions?

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).

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.

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.

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

Replies

Hi,


It's currently impossible ⟹ see this answer on Stackoverflow.

"I talked to Apple Engineers during WWDC19 Accessibility and Testing Labs and they said it is not possible right now. The reason why accessibility is not available during testing are security concerns. What they also said is that they don't use UITests for testing UIAccessibility and when creating accessibility elements support two cases - when there are UITests running and not."


You have also these 2 questions to have further information if need be:

- Performing UIAccessibilityCustomAction from UITests.

- UITest: how to test custom accessibility actions?