During Xcode UI Testing, how do I insertText for a UIView that conforms to UIKeyInput?
I created a CodeInputView that conforms to UIKeyInput.
When I record myself manually entering a code, Xcode writes app.typeText("1234").
But, when I try to play that back, I get the error UI Testing Failure - Neither element nor any descendant has keyboard focus. And, none of the solutions to that question has worked.
The
CodeInputViewneeds focus before typing text will work. Access the input by either its placeholder text or set the accessibility label manually.