Forcing keyboard entry in XCTest?

I'm trying to type a character of a string into a text field with Swift:


        let textField2 = element.childrenMatchingType(.TextField).elementBoundByIndex(1)
        textField2.tap()
        textField2.typeText(String(passkey[passkey.startIndex]))


However, I'm getting the dreaded "UI Testing Failure - Neither element nor any descendant has keyboard focus. Element:" error message.


Since I'm for sure tapping this field, and since the iPad's keyboard appears when this tap takes place, I'm led to believe that this is a bug in XCTest. To work around this for now, I'd like to just force keyboard entry, even if XCTest doesn't think there's a field to accept such text.

Is there a way to force keyboard entry?

Replies

Hi,


I'm having this issue with iOS Simulator, with Option, Simulator -> Hardware -> Keyboard -> Connect Hardware Keyboard on ON, if you're on Simulator too, try to switch it off and it might work.


I Hope it could help you.

Please make sure to file a bug report so that we can investigate your issue.

Thanks a lot for the suggestion. Unfortunately it didn't work for me. I actually had already tried that, since that solved this problem for some others.

Thanks! I've done so:

23716281

Try


Hardware > Keyboard > Uses the Same Layout as OS X - CHECKED

Hardware > Keyboard > Connect Hardware Keyboard - UNCHECKED

Hardware > Keyboard > Toggle Software Keyboard - ON


These settings worked for me.

I am facing similar issue. Is this resolved.