One of my screen has multiple text fields, I can land to this screen from different other screens. In each case I am making one or another text field as first responder. I a
I have observed some instances where
XCUIApplication().textFields[{index/identifier}].selected
does not return true even when I had my cursor focussed on the text field but I was able to enter text with .typeText()
. However, .enabled
correctly returns true , It appears 'enabled' value represents that UI element has accessibility enabled and you can interact with it.
Not a clean solution but you can try,
XCUIApplication().textFields.elementMatchingPredicate("predicate")
or .elementMatchingType()
to get XCUIElement and write your test block while handling the exception condition with guard
statement to throw appropriate error if the textField is not found.