-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add accessibility identifier in AccessibilityMarker #228
Conversation
dcb06e4
to
1e86122
Compare
var identifier: String? { | ||
if let accessibilityIdentifier = value(forKey: "accessibilityIdentifier") as? String { | ||
return accessibilityIdentifier | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no "clean" way to access the accessibilityIdentifier
for an NSObject
, since it's only available for objects that conform to UIAccessibilityIdentification
(doc) I tried using the accessibilityIdentifierBlock
(doc), but that yielded no results, so I've opted to pull the value using key values. I'm open to suggestions though if ya'll have any!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the following work?
if let typedSelf = self as? UIAccessibilityIdentification {
return typedSelf.accessibilityIdentifier
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this, but it was not triggering any of the UIKIt views.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, okay yes I vaguely remember now having a discussion with @RoyalPineapple about something very similar. I forget the context, but perhaps he can recall what he ended up doing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the solution here of testing for known conformance before using the key/value as a fallback works well enough. This bug is frustrating every time it comes up.
1e86122
to
24b20ed
Compare
@@ -714,7 +720,7 @@ extension UIView { | |||
fileprivate extension NSObject { | |||
var customContent: [(label: String, value: String, isImportant:Bool)] { | |||
// Github runs tests on specific iOS versions against specific versions of Xcode in CI. | |||
// Forward deployment on old versions of Xcode require a compile time check which require diferentiation by swift version rather than iOS SDK. | |||
// Forward deployment on old versions of Xcode require a compile time check which require differentiation by swift version rather than iOS SDK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks 👍🏻
Adds a new
identifier
property to theAccessibilityMarker
object which stores theaccessibilityIdentifier
for an element. This unique identifier can be used for identifying elements in UITests and is not visible to users.