Ui Testing Failure - Neither Element Nor Any Descendant Has Keyboard Focus on Textview

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

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

Neither element nor any descendant has keyboard focus when running XCTestCase in a real iPhone

I decided to answer myself rather than closing the question. I'll tell what went wrong in my code. The main mistake I have done was continueAfterFailure set as true. Because of that, the error shown in the wrong line not the actual error throwing line.

So the solution is,

continueAfterFailure = false

and

usernameTextField.tap()
sleep(2)
usernameTextField.typeText("TEST")

There should be a small waiting time till keyboard appears in the web view before type text.

UI test fails when it types text into a text view when run by an Xcode bot

I found a solution for my case and I hope it helps you as well.

In my setUp() and tearDown() (seems redundant I know) I put XCUIApplication().terminate(). This is ensuring that the app is terminated before running the next test and it seems to be doing the job.

override func setUp() {
XCUIApplication().terminate()
super.setUp()
continueAfterFailure = false
XCUIApplication().launch()
}
override func tearDown() {
super.tearDown()
XCUIApplication().terminate()
}

I filed a bug with Apple but for the time being this is getting me around the error that you were seeing. Hope that helps!



Related Topics



Leave a reply



Submit