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
Based on @hris.to's excellent answer, I put together this little extension (works in Swift 4 as well)...
extension XCUIElement { func hasFocus() -> Bool { let hasKeyboardFocus = (self.value(forKey: "hasKeyboardFocus") as? Bool) ?? false return hasKeyboardFocus } }