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
How to Load My Own Reality Composer Scene into Realitykit
Disable Scrolling in Swiftui List/Form
Accessor Gives the Wrong Value in Swift 1.2/2.0 Release Build Only
Collectionview Not Display Data After Parsing JSON
How to Declare Swift Implicitly Unwrapped Optional as a Constant
Is There a Preferred Technique to Prohibit Pasting into a Uitextfield
Swift 3 - Uibutton Adding Settitle from Plist and Database
Expand and Contract Tableview Cell When Tapped, in Swift
Codable Class Does Not Conform to Protocol Decodable
How to Request a Desktop Version of a Webpage Using Uiwebview in Swift 3.0
Why Does Realitykit Memory Does Not Clear After Deinit Called
Why Does the Following Code Crash on an iPhone 5 But Not an iPhone 5S
How to Use Trailing Closure in If Condition
How to Delete an Item in a Collection View with a Button in the Cell
How Do Generators Whose Element Is Optional Know When They'Ve Reached the End
Google API - Invalid Credentials
No Value Associated with Key Codingkeys While Trying to Get Data from Github API in Xcode App