Let's say we have UIView and it contains two UILabels. For automation test to access one of the label, we've set accessibilityIdentifier to one of the label.
Now, we want to support VoiceOver on our app. I've set isAccessibilityElement to true to VoiceOver. VoiceOver works well but the automation test is failing and saying, he can't identify the label with the accessibilityIdentifier.
I believe there is a way for automation test and VoiceOver to coexist. Is there a way, we can work around this?
I tried something like this. (isAccessibilityElement = false)
isAccessibilityElement = false
var elements = [Any]()
let accessibilityElement = UIAccessibilityElement(accessibilityContainer: self)
accessibilityElement.accessibilityHint = "VoiceOver, read this"
accessibilityElement.accessibilityFrameInContainerSpace = bounds
elements.append(accessibilityElement)
elements.append(label1)
elements.append(label2)
accessibilityElements = elements
---
private let label1 = {
let label = UILabel()
label.text = "label1"
label.accessibilityIdentifier = "label1"
return label
}()