Search code examples
iosaccessibilityxctestxcode-ui-testinguiaccessibility

Performing UIAccessibilityCustomAction from UITests


I've got a subclass of UIView, let's say it's class DemoView: UIView { } which contains UILabel and UIButton. I needed to group it and add UIAccessibilityCustomAction so I've overriden the var accessibilityElements: [Any]? and used union to connect both elements. I've also assigned "Users" string to accessibilityLabel.

From user perspective this works as it should, VoiceOver reads Users and then user can select custom action which is named Edit.

Problem is that I don't know how can I fire this custom action from UITests. I know that XCUIElement contains array of UICustomActions and I can get its selector but then what?


Solution

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

    I recommend making a suggestion using Feedback Assistant.