XCUITest: typeText() fails when simulator software keyboard not enabled?

I have an XCUITest that finds a secureTextField, .tap()s it, and then uses .typeText() to enter a value, then finds a second secureTextField and repeats the process with the second field.


When the test is run against the Simulator when Toggle Software Keyboard is not checked, the second .typeText() call fails because it complains that the field does not have focus. Watching the Simulator, I can see that the first field gains focus (probably from the .tap) and the field fills with (bulleted) text. When the second field gets its .tap(), the field looks like it becomes active (I can see the insertion indicator), but then the keyboard slides out, and the test barfs.


But I check Toggle Software Keyboard, and re-run the test, it succeeds.


Am I doing something wrong?

For what it's worth, I run into the same thing. The only, laborsome, fix I've found is to make sure, manually, that the simulator has it enabled.

After the tap(), wait for few seconds before actually entering text using typeText().

I think this is actually related to the "Connect Hardware Keyboard" flag. When connect hardware keyboard is checked, there is issues with presentation/dismissal of the simulator keyboard

This problem does not happen anymore with Xcode 12 beta and iOS 14 simulator
Premature joy, sorry. The problem reappeared after a while. But "Erase All Content And Settings..." helps
XCUITest: typeText() fails when simulator software keyboard not enabled?
 
 
Q