1 year ago
#368405
Michael Vescovo
How do I set an accessibility label in SwiftUI while still being able to test the visible text in a UI test?
Suppose I have an element on screen that shows the time left until an event which looks like this:
Time left: 3mo 20d 19h 59min. 21s.
But when using VoiceOver it will read it as
three mo, twenty d, nineteen h, fifty nine minutes, twenty one's.
So I put an accessibility label so it reads like
three months, twenty days, nineteen hours, fifty nine minutes, twenty one seconds.
However now in my UI test I can only see the accessibility label. I've lost the ability to test the text that's actually visible on the screen. I want to test both the visible and audible text, not just one or the other.
Am I doing it the wrong way and if so what is the correct way, or is there another way to test the visible text after adding an accessibilityLabel?
Thanks :)
ios
swiftui
xctest
0 Answers
Your Answer