UI Testing Failure - Neither element nor any descendant has keyboard focus on secureTextField

Bartłomiej Semańczyk picture Bartłomiej Semańczyk · Aug 24, 2015 · Viewed 31k times · Source

This is my case:

let passwordSecureTextField = app.secureTextFields["password"]
passwordSecureTextField.tap()
passwordSecureTextField.typeText("wrong_password") //here is an error

UI Testing Failure - Neither element nor any descendant has keyboard focus. Element:

What is wrong? This is working nice for normal textFields, but problem arise only with secureTextFields. Any workarounds?

Answer

Ted Kaminski picture Ted Kaminski · Dec 4, 2015

This issue caused me a world of pain, but I've managed to figure out a proper solution. In the Simulator, make sure 'Hardware -> Keyboard -> Connect hardware keyboard' is off.